bo

package
v1.1.24 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alarm

type Alarm struct {
	Receiver          string           `json:"receiver"`
	Status            vobj.AlertStatus `json:"status"`
	Alerts            []*Alert         `json:"alerts"`
	GroupLabels       *vobj.Labels     `json:"groupLabels"`
	CommonLabels      *vobj.Labels     `json:"commonLabels"`
	CommonAnnotations vobj.Annotations `json:"commonAnnotations"`
	ExternalURL       string           `json:"externalURL"`
	Version           string           `json:"version"`
	GroupKey          string           `json:"groupKey"`
	TruncatedAlerts   int32            `json:"truncatedAlerts"`
}

Alarm alarm detail info

func (*Alarm) Index

func (a *Alarm) Index() string

Index gen alarm index

func (*Alarm) Message

func (a *Alarm) Message() *watch.Message

Message gen alarm message

func (*Alarm) String

func (a *Alarm) String() string

type Alert

type Alert struct {
	Status       vobj.AlertStatus `json:"status"`
	Labels       *vobj.Labels     `json:"labels"`
	Annotations  vobj.Annotations `json:"annotations"`
	StartsAt     *types.Time      `json:"startsAt"`
	EndsAt       *types.Time      `json:"endsAt"`
	GeneratorURL string           `json:"generatorURL"`
	Fingerprint  string           `json:"fingerprint"`
	Value        float64          `json:"value"`
}

Alert alert detail info

func NewAlertWithAlertStrInfo

func NewAlertWithAlertStrInfo(info string) (*Alert, error)

NewAlertWithAlertStrInfo create alert from alert string

func (*Alert) GetExternalURL

func (a *Alert) GetExternalURL() string

GetExternalURL gen alert external url

func (*Alert) GetFingerprint

func (a *Alert) GetFingerprint() string

GetFingerprint gen alert fingerprint

func (*Alert) Index

func (a *Alert) Index() string

Index gen alert index

func (*Alert) MarshalBinary added in v1.1.0

func (a *Alert) MarshalBinary() (data []byte, err error)

func (*Alert) Message

func (a *Alert) Message() *watch.Message

Message gen alert message

func (*Alert) PushedFlag added in v1.1.0

func (a *Alert) PushedFlag() string

PushedFlag gen pushed flag

func (*Alert) String

func (a *Alert) String() string

func (*Alert) UnmarshalBinary added in v1.1.0

func (a *Alert) UnmarshalBinary(data []byte) error

type Datasource

type Datasource struct {
	// 数据源类型
	Category vobj.DatasourceType `json:"category,omitempty"`
	// 存储器类型
	StorageType vobj.StorageType `json:"storage_type,omitempty"`
	// 数据源配置 json
	Config map[string]string `json:"config,omitempty"`
	// 数据源地址
	Endpoint string `json:"endpoint,omitempty"`
	// 数据源ID
	ID uint32 `json:"id,omitempty"`
}

Datasource 数据源明细

type GetMetricsParams

type GetMetricsParams struct {
	Endpoint string            `json:"endpoint"`
	Config   map[string]string `json:"config"`
	// 存储类型
	StorageType vobj.StorageType `json:"storageType"`
}

GetMetricsParams 查询指标请求参数

type IStrategy added in v1.1.0

type IStrategy interface {
	watch.Indexer
	Message() *watch.Message
	BuilderAlarmBaseInfo() *Alarm
	GetTeamID() uint32
	GetStatus() vobj.Status
	GetReceiverGroupIDs() []uint32
	GetLabelNotices() []*LabelNotices
	GetAnnotations() map[string]string
	GetInterval() *types.Duration
	Eval(ctx context.Context) (map[watch.Indexer]*datasource.Point, error)
	IsCompletelyMeet(values []*datasource.Value) (map[string]any, bool)
}

type LabelNotices added in v1.1.0

type LabelNotices struct {
	// label key
	Key string `json:"key,omitempty"`
	// label value 支持正则
	Value string `json:"value,omitempty"`
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
}

type MetricDetail

type MetricDetail struct {
	// 指标名称
	Name string `json:"name"`
	// 帮助信息
	Help string `json:"help"`
	// 类型
	Type string `json:"type"`
	// 标签集合
	Labels map[string][]string `json:"labels"`
	// 指标单位
	Unit string `json:"unit"`
}

MetricDetail 指标详情

type PushMetricParams

type PushMetricParams struct {
	// 指标明细
	*MetricDetail
	// 数据源ID
	DatasourceID uint32 `json:"datasourceId"`
	// 是否完成
	Done bool `json:"done"`
	// 团队ID
	TeamID uint32 `json:"teamId"`
}

PushMetricParams 推送指标请求参数

type QueryQLParams

type QueryQLParams struct {
	// 查询指标请求参数
	GetMetricsParams
	// 查询QL
	QueryQL string `json:"queryQL"`
	// 时间范围
	TimeRange []string `json:"timeRange"`
	// 步长
	Step uint32 `json:"step"`
}

QueryQLParams 查询QL请求参数

type StrategyDomain added in v1.1.0

type StrategyDomain struct {
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
	// 自定义接收者匹配对象
	LabelNotices []*LabelNotices `json:"labelNotices,omitempty"`
	// 策略ID
	ID uint32 `json:"id,omitempty"`
	// 策略等级ID
	LevelID uint32 `json:"levelId,omitempty"`
	// 团队ID
	TeamID uint32 `json:"teamId,omitempty"`
	// 状态
	Status vobj.Status `json:"status,omitempty"`
	// 策略名称
	Alert string `json:"alert,omitempty"`
	// 阈值
	Threshold float64 `json:"threshold,omitempty"`
	// 策略标签
	Labels *vobj.Labels `json:"labels,omitempty"`
	// 策略注解
	Annotations vobj.Annotations `json:"annotations,omitempty"`
	// 域名
	Domain string `json:"domain,omitempty"`
	// 超时时间
	Timeout uint32 `json:"timeout,omitempty"`
	// 执行频率
	Interval *types.Duration `json:"interval,omitempty"`
	// 端口
	Port uint32 `json:"port,omitempty"`
	// 类型
	Type vobj.StrategyType `json:"type,omitempty"`
}

StrategyDomain 证书策略

func (*StrategyDomain) BuilderAlarmBaseInfo added in v1.1.0

func (s *StrategyDomain) BuilderAlarmBaseInfo() *Alarm

BuilderAlarmBaseInfo 构建告警基础信息

func (*StrategyDomain) Eval added in v1.1.0

Eval 策略评估

func (*StrategyDomain) GetAnnotations added in v1.1.0

func (s *StrategyDomain) GetAnnotations() map[string]string

func (*StrategyDomain) GetInterval added in v1.1.0

func (s *StrategyDomain) GetInterval() *types.Duration

func (*StrategyDomain) GetLabelNotices added in v1.1.0

func (s *StrategyDomain) GetLabelNotices() []*LabelNotices

func (*StrategyDomain) GetReceiverGroupIDs added in v1.1.0

func (s *StrategyDomain) GetReceiverGroupIDs() []uint32

func (*StrategyDomain) GetStatus added in v1.1.0

func (s *StrategyDomain) GetStatus() vobj.Status

func (*StrategyDomain) GetTeamID added in v1.1.0

func (s *StrategyDomain) GetTeamID() uint32

func (*StrategyDomain) Index added in v1.1.0

func (s *StrategyDomain) Index() string

Index 策略唯一索引

func (*StrategyDomain) IsCompletelyMeet added in v1.1.0

func (s *StrategyDomain) IsCompletelyMeet(values []*datasource.Value) (map[string]any, bool)

IsCompletelyMeet 判断策略是否完全满足条件

func (*StrategyDomain) Message added in v1.1.0

func (s *StrategyDomain) Message() *watch.Message

Message 策略转消息

func (*StrategyDomain) String added in v1.1.0

func (s *StrategyDomain) String() string

String 策略转字符串

type StrategyEndpoint added in v1.1.0

type StrategyEndpoint struct {
	// 类型
	Type vobj.StrategyType `json:"type,omitempty"`
	// url 地址
	Url string `json:"url,omitempty"`
	// 超时时间
	Timeout uint32 `json:"timeout,omitempty"`
	// 状态码 200 404 500
	StatusCode uint32 `json:"statusCode,omitempty"`
	// 请求头
	Headers map[string]string `json:"headers,omitempty"`
	// 请求体
	Body string `json:"body,omitempty"`
	// 请求方式
	Method vobj.HttpMethod `json:"method,omitempty"`
	// 相应时间阈值
	Threshold float64 `json:"threshold,omitempty"`
	// 策略标签
	Labels *vobj.Labels `json:"labels,omitempty"`
	// 策略注解
	Annotations vobj.Annotations `json:"annotations,omitempty"`
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
	// 自定义接收者匹配对象
	LabelNotices []*LabelNotices `json:"labelNotices,omitempty"`
	// 团队ID
	TeamID uint32 `json:"teamId,omitempty"`
	// 状态
	Status vobj.Status `json:"status,omitempty"`
	// 策略名称
	Alert string `json:"alert,omitempty"`
	// 执行频率
	Interval *types.Duration `json:"interval,omitempty"`
	// 策略级别ID
	LevelID uint32 `json:"levelId,omitempty"`
	// 策略ID
	ID uint32 `json:"id,omitempty"`
}

StrategyEndpoint 端点响应时间、状态码策略

func (*StrategyEndpoint) BuilderAlarmBaseInfo added in v1.1.0

func (e *StrategyEndpoint) BuilderAlarmBaseInfo() *Alarm

func (*StrategyEndpoint) Eval added in v1.1.0

func (*StrategyEndpoint) GetAnnotations added in v1.1.0

func (e *StrategyEndpoint) GetAnnotations() map[string]string

func (*StrategyEndpoint) GetInterval added in v1.1.0

func (e *StrategyEndpoint) GetInterval() *types.Duration

func (*StrategyEndpoint) GetLabelNotices added in v1.1.0

func (e *StrategyEndpoint) GetLabelNotices() []*LabelNotices

func (*StrategyEndpoint) GetReceiverGroupIDs added in v1.1.0

func (e *StrategyEndpoint) GetReceiverGroupIDs() []uint32

func (*StrategyEndpoint) GetStatus added in v1.1.0

func (e *StrategyEndpoint) GetStatus() vobj.Status

func (*StrategyEndpoint) GetTeamID added in v1.1.0

func (e *StrategyEndpoint) GetTeamID() uint32

func (*StrategyEndpoint) Index added in v1.1.0

func (e *StrategyEndpoint) Index() string

func (*StrategyEndpoint) IsCompletelyMeet added in v1.1.0

func (e *StrategyEndpoint) IsCompletelyMeet(values []*datasource.Value) (map[string]any, bool)

func (*StrategyEndpoint) Message added in v1.1.0

func (e *StrategyEndpoint) Message() *watch.Message

func (*StrategyEndpoint) String added in v1.1.0

func (e *StrategyEndpoint) String() string

type StrategyMetric added in v1.1.0

type StrategyMetric struct {
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
	// 自定义接收者匹配对象
	LabelNotices []*LabelNotices `json:"labelNotices,omitempty"`
	// 策略ID
	ID uint32 `json:"id,omitempty"`
	// 策略等级ID
	LevelID uint32 `json:"levelId,omitempty"`
	// 策略名称
	Alert string `json:"alert,omitempty"`
	// 策略语句
	Expr string `json:"expr,omitempty"`
	// 策略持续时间
	For *types.Duration `json:"for,omitempty"`
	// 持续次数
	Count uint32 `json:"count,omitempty"`
	// 持续的类型
	SustainType vobj.Sustain `json:"sustainType,omitempty"`
	// 多数据源持续类型
	MultiDatasourceSustainType vobj.MultiDatasourceSustain `json:"multiDatasourceSustainType,omitempty"`
	// 策略标签
	Labels *vobj.Labels `json:"labels,omitempty"`
	// 策略注解
	Annotations vobj.Annotations `json:"annotations,omitempty"`
	// 执行频率
	Interval *types.Duration `json:"interval,omitempty"`
	// 数据源
	Datasource []*Datasource `json:"datasource,omitempty"`
	// 策略状态
	Status vobj.Status `json:"status,omitempty"`
	// 策略采样率
	Step uint32 `json:"step,omitempty"`
	// 判断条件
	Condition vobj.Condition `json:"condition,omitempty"`
	// 阈值
	Threshold float64 `json:"threshold,omitempty"`
	// 团队ID
	TeamID uint32 `json:"teamId,omitempty"`
}

StrategyMetric 策略明细

func (*StrategyMetric) BuilderAlarmBaseInfo added in v1.1.0

func (s *StrategyMetric) BuilderAlarmBaseInfo() *Alarm

func (*StrategyMetric) Eval added in v1.1.0

func (*StrategyMetric) GetAnnotations added in v1.1.0

func (s *StrategyMetric) GetAnnotations() map[string]string

func (*StrategyMetric) GetInterval added in v1.1.0

func (s *StrategyMetric) GetInterval() *types.Duration

func (*StrategyMetric) GetLabelNotices added in v1.1.0

func (s *StrategyMetric) GetLabelNotices() []*LabelNotices

func (*StrategyMetric) GetReceiverGroupIDs added in v1.1.0

func (s *StrategyMetric) GetReceiverGroupIDs() []uint32

func (*StrategyMetric) GetStatus added in v1.1.0

func (s *StrategyMetric) GetStatus() vobj.Status

func (*StrategyMetric) GetTeamID added in v1.1.0

func (s *StrategyMetric) GetTeamID() uint32

func (*StrategyMetric) Index added in v1.1.0

func (s *StrategyMetric) Index() string

Index 策略唯一索引

func (*StrategyMetric) IsCompletelyMeet added in v1.1.0

func (s *StrategyMetric) IsCompletelyMeet(values []*datasource.Value) (map[string]any, bool)

IsCompletelyMeet 判断策略是否完全满足条件

func (*StrategyMetric) Message added in v1.1.0

func (s *StrategyMetric) Message() *watch.Message

Message 策略转消息

func (*StrategyMetric) String added in v1.1.0

func (s *StrategyMetric) String() string

type StrategyPing added in v1.1.0

type StrategyPing struct {
	// 类型
	Type vobj.StrategyType `json:"type,omitempty"`
	// 策略ID
	StrategyID uint32 `json:"strategy_id,omitempty"`
	// 团队ID
	TeamID uint32 `json:"teamId,omitempty"`
	// 状态
	Status vobj.Status `json:"status,omitempty"`
	// 策略名称
	Alert string `json:"alert,omitempty"`
	// 执行频率
	Interval *types.Duration `json:"interval,omitempty"`
	// 策略级别ID
	LevelID uint32 `json:"levelId,omitempty"`
	// 超时时间
	Timeout uint32 `json:"timeout,omitempty"`
	// 策略标签
	Labels *vobj.Labels `json:"labels,omitempty"`
	// 策略注解
	Annotations vobj.Annotations `json:"annotations,omitempty"`
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
	// 域名或IP
	Address string `json:"address,omitempty"`

	// 总包数
	TotalPackets float64 `json:"totalPackets,omitempty"`
	// 成功包数
	SuccessPackets float64 `json:"successPackets,omitempty"`
	// 丢包率
	LossRate float64 `json:"lossRate,omitempty"`
	// 最小延迟
	MinDelay float64 `json:"minDelay,omitempty"`
	// 最大延迟
	MaxDelay float64 `json:"maxDelay,omitempty"`
	// 平均延迟
	AvgDelay float64 `json:"avgDelay,omitempty"`
	// 标准差
	StdDevDelay float64 `json:"stdDevDelay,omitempty"`
}

StrategyPing ping 策略

func (*StrategyPing) BuilderAlarmBaseInfo added in v1.1.0

func (s *StrategyPing) BuilderAlarmBaseInfo() *Alarm

func (*StrategyPing) Eval added in v1.1.0

func (*StrategyPing) GetAnnotations added in v1.1.0

func (s *StrategyPing) GetAnnotations() map[string]string

func (*StrategyPing) GetInterval added in v1.1.0

func (s *StrategyPing) GetInterval() *types.Duration

func (*StrategyPing) GetLabelNotices added in v1.1.0

func (s *StrategyPing) GetLabelNotices() []*LabelNotices

func (*StrategyPing) GetReceiverGroupIDs added in v1.1.0

func (s *StrategyPing) GetReceiverGroupIDs() []uint32

func (*StrategyPing) GetStatus added in v1.1.0

func (s *StrategyPing) GetStatus() vobj.Status

func (*StrategyPing) GetTeamID added in v1.1.0

func (s *StrategyPing) GetTeamID() uint32

func (*StrategyPing) Index added in v1.1.0

func (s *StrategyPing) Index() string

func (*StrategyPing) IsCompletelyMeet added in v1.1.0

func (s *StrategyPing) IsCompletelyMeet(values []*datasource.Value) (map[string]any, bool)

IsCompletelyMeet checks if the ping metrics meet the strategy criteria

func (*StrategyPing) Message added in v1.1.0

func (s *StrategyPing) Message() *watch.Message

func (*StrategyPing) String added in v1.1.0

func (s *StrategyPing) String() string

Jump to

Keyboard shortcuts

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