boot

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleFileSuffix = ".rule.yaml"
)
View Source
const (
	Version = "1.0.0"
)

Variables

This section is empty.

Functions

func FsWatcher

func FsWatcher(path string, callback func(event *fsnotify.Event, e error))

FsWatcher can listen file or dir change, if you get a change event, will call callback function

func RenderAlertMessage

func RenderAlertMessage(writer http.ResponseWriter, request *http.Request)

Types

type AlertContent

type AlertContent struct {
	Rule     *conf.Rule
	Match    *Match
	StartsAt *time.Time
	EndsAt   *time.Time
	State    AlertState
}

func (*AlertContent) GetAlertMessage

func (ac *AlertContent) GetAlertMessage(generatorURL string) string

func (*AlertContent) HasResolved

func (ac *AlertContent) HasResolved() bool

type AlertMessage

type AlertMessage struct {
	UniqueId string `json:"id"`
	Path     string `json:"path"`
	Payload  string `json:"payload"`
	StartsAt *time.Time
}

type AlertSampleMessage

type AlertSampleMessage struct {
	ES    conf.EsConfig `json:"es"`
	Index string        `json:"index"`
	Ids   []string      `json:"ids"`
}

type AlertState

type AlertState int
const (
	Pending AlertState = iota
	Resolved
)

type ElasticAlert

type ElasticAlert struct {
	// contains filtered or unexported fields
}

func NewElasticAlert

func NewElasticAlert(c *conf.AppConfig, opts *conf.FlagOption) *ElasticAlert

func (*ElasticAlert) SetAppConf

func (ea *ElasticAlert) SetAppConf(c *conf.AppConfig)

func (*ElasticAlert) Start

func (ea *ElasticAlert) Start()

func (*ElasticAlert) Stop

func (ea *ElasticAlert) Stop()

type ElasticAlertPrometheusMetrics

type ElasticAlertPrometheusMetrics struct {
	Query         sync.Map // map[string]QueryMetrics
	OpRedis       sync.Map // map[string]OpRedisMetrics
	WebhookNotify sync.Map // map[string]WebhookNotifyMetrics
}

func NewElasticAlertPrometheusMetrics

func NewElasticAlertPrometheusMetrics() *ElasticAlertPrometheusMetrics

type ElasticJob

type ElasticJob struct {
	Scheduler *gocron.Scheduler
	StartsAt  *time.Time
	EndsAt    *time.Time
}

type FileLoader

type FileLoader struct {
	RulesFolder          string `default:"rules"`
	RulesFolderRecursion bool   `default:"true"`
	// contains filtered or unexported fields
}

func (*FileLoader) GetRules

func (fl *FileLoader) GetRules() map[string]*conf.Rule

func (*FileLoader) InjectConfig

func (fl *FileLoader) InjectConfig(config map[string]any)

func (*FileLoader) ReloadSchedulerJob

func (fl *FileLoader) ReloadSchedulerJob(engine *ElasticAlert)

type FrequencyRule

type FrequencyRule struct {
}

func (*FrequencyRule) FilterMatchCondition

func (fr *FrequencyRule) FilterMatchCondition(r *conf.Rule, matches []Match) *Match

func (*FrequencyRule) GetMatches

func (fr *FrequencyRule) GetMatches(r *conf.Rule, resultHits []any) []Match

type Loader

type Loader interface {
	InjectConfig(config map[string]any)
	GetRules() map[string]*conf.Rule
	ReloadSchedulerJob(*ElasticAlert)
}

func NewLoaderInstance

func NewLoaderInstance(t string) Loader

type Match

type Match struct {
	Ids        []string
	StartsAt   time.Time
	EndsAt     time.Time
	HitsNumber int
	// contains filtered or unexported fields
}

func (*Match) Fingerprint

func (mc *Match) Fingerprint() string

type OpRedisMetrics

type OpRedisMetrics struct {
	UniqueId string
	Path     string
	Cmd      string
	Key      string
	Status   int
	Value    int64
}

type QueryMetrics

type QueryMetrics struct {
	UniqueId  string
	Path      string
	EsAddress string
	Index     string
	Status    int
	Value     int64
}

type RuleStatusCollector

type RuleStatusCollector struct {
	Ea                *ElasticAlert
	AppInfoDesc       *prometheus.Desc
	RuleStatusDesc    *prometheus.Desc
	LinkRedisDesc     *prometheus.Desc
	QueryDesc         *prometheus.Desc
	OpRedisDesc       *prometheus.Desc
	WebhookNotifyDesc *prometheus.Desc
}

func NewRuleStatusCollector

func NewRuleStatusCollector(ea *ElasticAlert) *RuleStatusCollector

func (*RuleStatusCollector) Collect

func (rc *RuleStatusCollector) Collect(ch chan<- prometheus.Metric)

func (*RuleStatusCollector) Describe

func (rc *RuleStatusCollector) Describe(ch chan<- *prometheus.Desc)

type RuleType

type RuleType interface {
	GetMatches(r *conf.Rule, hits []any) []Match
	FilterMatchCondition(r *conf.Rule, matches []Match) *Match
}

func NewRuleType

func NewRuleType(t string) RuleType

type WebhookNotifyMetrics

type WebhookNotifyMetrics struct {
	UniqueId string
	Path     string
	Status   int
	Value    int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL