initial

package
v0.0.0-...-b9dc9a6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DbDriverName = "mysql"

Variables

View Source
var InitialData = []string{"ALTER TABLE alert ADD UNIQUE INDEX ruleid_labels_firedat(`rule_id`, `labels`(255),`fired_at`);", `INSERT INTO  users  ( name,  password ) VALUES ('admin', 'e10adc3949ba59abbe56e057f20f883e');`}

Functions

func Filter

func Filter(alerts map[int64][]Record, maxCount map[int64]int) map[string][]common.Ready2Send

Filter的作用:收集每个报警渠道以及该渠道包含的需要发送的告警信息列表,返回map[string][]common.Ready2Send 返回值: // key是告警渠道信息,如DINGTALK http://127.0.0.1/ tokenxxxx。

// value是各个告警信息的列表,下面进行遍历每个告警,进行发送。就是Ready2Send的切片集合

func InitDb

func InitDb()

func RecoverSender

func RecoverSender(SendClass map[string]map[[2]int64]*common.Ready2Send, now string)

send recovery message if alert recovered.

func Send2Hook

func Send2Hook(content []common.Ready2Send, sendTime string, t string, url string)

func SendAll

func SendAll(method string, from string, param map[string]string, content []common.Ready2Send, sendTime string)

func SendRecover

func SendRecover(url string, from string, param map[string]string, content []common.Ready2Send, sendTime string)

func Sender

func Sender(SendClass map[string][]common.Ready2Send, now string)

在规则触发后,调用此方法发送告警。

参数1:SendClass:key是告警渠道信息,如DINGTALK http://127.0.0.1/ tokenxxxx。

value是各个告警信息的列表,下面进行遍历每个告警,进行发送。就是Ready2Send的切片集合

参数2:当前时间

func UpdateMaintainlist

func UpdateMaintainlist()

Types

type Record

type Record struct {
	Id              int64
	RuleId          int64
	Value           float64
	Count           int
	Summary         string
	Description     string
	Hostname        string
	ConfirmedBefore *time.Time
	FiredAt         *time.Time
	Labels          string
}

与数据库alert表一一对应

type RecoverRecord

type RecoverRecord struct {
	Id       int64
	RuleId   int64
	Value    float64
	Count    int
	Summary  string
	Hostname string
}

Jump to

Keyboard shortcuts

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