Documentation ¶
Index ¶
- Constants
- func BuildDuration(duration string) int64
- func Formatter(format string, data any) (s string)
- func NewAlarm(group *Group, rule *Rule, results []*Result) (*Alarm, *Alarm, bool)
- func SetAlarmCache(cache AlarmCache)
- type Alarm
- type AlarmCache
- type AlarmStatus
- type Alarms
- type Alert
- type Alerter
- type Alerting
- type AlertingOption
- type Annotation
- type Annotations
- func (l *Annotations) Description() string
- func (l *Annotations) Get(key string) string
- func (l *Annotations) Map() map[string]string
- func (l *Annotations) Scan(src any) error
- func (l *Annotations) String() string
- func (l *Annotations) Summary() string
- func (l *Annotations) Value() (driver.Value, error)
- type BasicAuth
- type Data
- type Datasource
- type DatasourceName
- type Group
- type Groups
- type Label
- type Labels
- func (l *Labels) Append(key, value string) *Labels
- func (l *Labels) AppendAll(m map[string]string) *Labels
- func (l *Labels) Get(key string) string
- func (l *Labels) GetInstance() string
- func (l *Labels) LevelId() uint32
- func (l *Labels) Map() map[string]string
- func (l *Labels) Scan(src any) error
- func (l *Labels) StrategyId() uint32
- func (l *Labels) String() string
- func (l *Labels) Value() (driver.Value, error)
- type Load
- type Metric
- type PromDatasource
- func (d *PromDatasource) GetBasicAuth() *BasicAuth
- func (d *PromDatasource) GetCategory() string
- func (d *PromDatasource) GetEndpoint() string
- func (d *PromDatasource) Query(_ context.Context, expr string, duration int64) (*QueryResponse, error)
- func (d *PromDatasource) WithBasicAuth(basicAuth *BasicAuth) Datasource
- type QueryResponse
- type Result
- type Rule
- type Store
Constants ¶
View Source
const ( MetricName = "__name__" MetricGroupName = "__group_name__" MetricGroupId = "__group_id__" MetricAlert = "alertname" MetricAlertId = "__alert_id__" MetricLevelId = "__level_id__" MetricInstance = "instance" MetricDescription = "description" MetricSummary = "summary" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alarm ¶
type Alarm struct { // 接收者 Receiver string `json:"receiver"` // 报警状态 Status AlarmStatus `json:"status"` // 告警列表 Alerts []*Alert `json:"alerts"` // 告警组标签 GroupLabels Labels `json:"groupLabels"` // 公共标签 CommonLabels map[string]string `json:"commonLabels"` // 公共注解 CommonAnnotations map[string]string `json:"commonAnnotations"` // 外部链接 ExternalURL string `json:"externalURL"` // 版本 Version string `json:"version"` // 告警组key GroupKey string `json:"groupKey"` // 截断告警数 TruncatedAlerts int32 `json:"truncate"` }
type AlarmCache ¶
type AlarmCache interface { // Get 获取当前规则下所有告警数据 Get(ruleId uint32) (*Alarm, bool) // Set 当前规则下告警数据 Set(ruleId uint32, alarm *Alarm) bool // Remove 删除告警 Remove(ruleId uint32) bool // SetNotifyAlert 当前规则下告警数据 SetNotifyAlert(alert *Alert) bool // RemoveNotifyAlert 删除告警 RemoveNotifyAlert(alert *Alert) bool // GetNotifyAlert 获取告警数据 GetNotifyAlert(alert *Alert) (*Alert, bool) // RangeNotifyAlerts range notify alerts RangeNotifyAlerts(f func(*Alert)) }
func NewAlarmCache ¶
func NewAlarmCache(cache cache.GlobalCache) AlarmCache
type AlarmStatus ¶
type AlarmStatus string
const ( // AlarmStatusFiring firing AlarmStatusFiring AlarmStatus = "firing" // AlarmStatusResolved resolved AlarmStatusResolved AlarmStatus = "resolved" )
type Alarms ¶
type Alarms struct { Alarms []*Alarm // contains filtered or unexported fields }
func NewAlarmList ¶
type Alert ¶
type Alert struct { // 告警状态 Status AlarmStatus `json:"status"` // 标签 Labels Labels `json:"labels"` // 注解 Annotations Annotations `json:"annotations"` // 开始时间 StartsAt string `json:"startsAt"` // 结束时间, 如果为空, 则表示未结束 EndsAt string `json:"endsAt"` // 告警生成链接 GeneratorURL string `json:"generatorURL"` // 指纹 Fingerprint string `json:"fingerprint"` }
type AlertingOption ¶
type AlertingOption func(*Alerting)
func WithDatasourceName ¶
func WithDatasourceName(datasourceName DatasourceName) AlertingOption
WithDatasourceName 设置数据源名称
type Annotation ¶
type Annotations ¶
func MapToAnnotations ¶
func MapToAnnotations(m map[string]string) *Annotations
MapToAnnotations 将map转换为注解
func (*Annotations) Description ¶
func (l *Annotations) Description() string
func (*Annotations) Get ¶
func (l *Annotations) Get(key string) string
func (*Annotations) Map ¶
func (l *Annotations) Map() map[string]string
func (*Annotations) Scan ¶
func (l *Annotations) Scan(src any) error
func (*Annotations) String ¶
func (l *Annotations) String() string
func (*Annotations) Summary ¶
func (l *Annotations) Summary() string
type Datasource ¶
type Datasource interface { Query(ctx context.Context, expr string, duration int64) (*QueryResponse, error) GetCategory() string GetEndpoint() string GetBasicAuth() *BasicAuth WithBasicAuth(basicAuth *BasicAuth) Datasource }
func NewDatasource ¶
func NewDatasource(datasourceName DatasourceName, endpoint string) Datasource
type DatasourceName ¶
type DatasourceName string
const (
PrometheusDatasource DatasourceName = "prometheus"
)
type Labels ¶
func (*Labels) GetInstance ¶
func (*Labels) StrategyId ¶
type PromDatasource ¶
type PromDatasource struct {
// contains filtered or unexported fields
}
func NewPrometheusDatasource ¶
func NewPrometheusDatasource(domain string) *PromDatasource
NewPrometheusDatasource 实例化数据源对象
func (*PromDatasource) GetBasicAuth ¶
func (d *PromDatasource) GetBasicAuth() *BasicAuth
func (*PromDatasource) GetCategory ¶
func (d *PromDatasource) GetCategory() string
func (*PromDatasource) GetEndpoint ¶
func (d *PromDatasource) GetEndpoint() string
func (*PromDatasource) Query ¶
func (d *PromDatasource) Query(_ context.Context, expr string, duration int64) (*QueryResponse, error)
Query 调用数据源查询数据
curl 'https://<domain>/api/v1/query?query=go_memstats_sys_bytes&time=1704785907'
func (*PromDatasource) WithBasicAuth ¶
func (d *PromDatasource) WithBasicAuth(basicAuth *BasicAuth) Datasource
type QueryResponse ¶
type QueryResponse struct { Status string `json:"status"` Data *Data `json:"data"` ErrorType string `json:"errorType"` Error string `json:"error"` }
func (*QueryResponse) String ¶
func (qr *QueryResponse) String() string
String QueryResponse to string
Click to show internal directories.
Click to hide internal directories.