boot

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleFileSuffix = ".rule.yaml"
)
View Source
const (
	Version = "1.1.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     *model.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           model.EsConfig `json:"es"`
	Index        string         `json:"index"`
	Ids          []string       `json:"ids"`
	Node         string         `json:"node"`
	Workload     string         `json:"workload"`
	Pod          string         `json:"pod"`
	Namespace    string         `json:"namespace"`
	Cluster      string         `json:"cluster"`
	QueryString  string         `json:"query_string"`
	BooleanQuery string         `json:"boolean_query"`
}

type AlertState

type AlertState int
const (
	Pending AlertState = iota
	Resolved
)

type ElasticAlert

type ElasticAlert struct {
	Loader Loader
	// 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 ElasticAlertMetrics

type ElasticAlertMetrics struct {
	UniqueId string
	//Path      string
	//EsAddress string
	Index string
	Key   string
	//Ids   string
	Node         string
	Workload     string
	Pod          string
	Namespace    string
	Cluster      string
	QueryString  string
	BooleanQuery string
	Value        int64
}

type ElasticAlertPrometheusMetrics

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

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"`
}

FileLoader static file loader TODO(jian): use https://github.com/spf13/viper instead.

func (*FileLoader) GetRules

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

func (*FileLoader) InjectConfig

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

func (*FileLoader) ReloadSchedulerJob

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

type FileWatcherLoader

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

FileWatcherLoader file watcher and dynamic load TODO(jian): use https://github.com/spf13/viper instead.

func (*FileWatcherLoader) GetRules

func (fl *FileWatcherLoader) GetRules() map[string]*model.Rule

func (*FileWatcherLoader) InjectConfig

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

func (*FileWatcherLoader) ReloadRules

func (fl *FileWatcherLoader) ReloadRules(engine *ElasticAlert)

func (*FileWatcherLoader) ReloadSchedulerJob

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

type FrequencyRule

type FrequencyRule struct {
}

func (*FrequencyRule) FilterMatchCondition

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

func (*FrequencyRule) GetMatches

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

type Loader

type Loader interface {
	InjectConfig(config map[string]any)
	GetRules() map[string]*model.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
	ElasticMetricsDesc *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 *model.Rule, hits []any) []Match
	FilterMatchCondition(r *model.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