bo

package
v1.1.45 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 16 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 生成告警索引

func (*Alarm) Message

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

Message 生成告警消息

func (*Alarm) String

func (a *Alarm) String() 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 从告警字符串信息创建告警结构体

func (*Alert) GetExternalURL

func (a *Alert) GetExternalURL() string

GetExternalURL 生成告警外部链接

func (*Alert) GetFingerprint

func (a *Alert) GetFingerprint() string

GetFingerprint 生成告警指纹

func (*Alert) Index

func (a *Alert) Index() string

Index 生成告警索引

func (*Alert) MarshalBinary added in v1.1.0

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

MarshalBinary 将告警信息编码为二进制

func (*Alert) Message

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

Message 生成告警消息

func (*Alert) PushedFlag added in v1.1.0

func (a *Alert) PushedFlag() string

PushedFlag 生成推送标识

func (*Alert) String

func (a *Alert) String() string

func (*Alert) UnmarshalBinary added in v1.1.0

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

UnmarshalBinary 将告警信息解码为告警结构体

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)
}

IStrategy 策略接口

type IStrategyEvent added in v1.1.38

type IStrategyEvent interface {
	IStrategy

	// SetValue 设置数据
	SetValue(msg *mq.Msg) IStrategyEvent
	// GetDatasource 获取数据源
	GetDatasource() []*MQDatasource
	// GetTopic 获取主题
	GetTopic() string
}

IStrategyEvent 事件策略统一接口

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

LabelNotices 自定义接收者匹配对象

type MQDatasource added in v1.1.38

type MQDatasource struct {
	TeamID uint32      `json:"team_id"`
	ID     uint32      `json:"id"`
	Status vobj.Status `json:"status"`

	Conf *conf.MQ `json:"conf"`
}

MQDatasource MQ 数据源配置

func (*MQDatasource) GetMQConfig added in v1.1.38

func (m *MQDatasource) GetMQConfig() *conf.MQ

GetMQConfig 获取 MQ 配置

func (*MQDatasource) Index added in v1.1.38

func (m *MQDatasource) Index() string

Index 实现 watch.Indexer 接口

func (*MQDatasource) String added in v1.1.38

func (m *MQDatasource) String() string

String 实现 fmt.Stringer 接口

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

GetAnnotations 获取策略注解

func (*StrategyDomain) GetInterval added in v1.1.0

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

GetInterval 获取执行频率

func (*StrategyDomain) GetLabelNotices added in v1.1.0

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

GetLabelNotices 获取自定义接收者匹配对象

func (*StrategyDomain) GetReceiverGroupIDs added in v1.1.0

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

GetReceiverGroupIDs 获取接收者组ID列表

func (*StrategyDomain) GetStatus added in v1.1.0

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

GetStatus 获取策略状态

func (*StrategyDomain) GetTeamID added in v1.1.0

func (s *StrategyDomain) GetTeamID() uint32

GetTeamID 获取团队ID

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

BuilderAlarmBaseInfo 生成告警基础信息

func (*StrategyEndpoint) Eval added in v1.1.0

Eval 评估策略

func (*StrategyEndpoint) GetAnnotations added in v1.1.0

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

GetAnnotations 获取策略注解

func (*StrategyEndpoint) GetInterval added in v1.1.0

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

GetInterval 获取执行频率

func (*StrategyEndpoint) GetLabelNotices added in v1.1.0

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

GetLabelNotices 获取自定义接收者匹配对象

func (*StrategyEndpoint) GetReceiverGroupIDs added in v1.1.0

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

GetReceiverGroupIDs 获取接收者组ID列表

func (*StrategyEndpoint) GetStatus added in v1.1.0

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

GetStatus 获取策略状态

func (*StrategyEndpoint) GetTeamID added in v1.1.0

func (e *StrategyEndpoint) GetTeamID() uint32

GetTeamID 获取团队ID

func (*StrategyEndpoint) Index added in v1.1.0

func (e *StrategyEndpoint) Index() string

Index 生成策略索引

func (*StrategyEndpoint) IsCompletelyMeet added in v1.1.0

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

IsCompletelyMeet 是否完全满足策略条件

func (*StrategyEndpoint) Message added in v1.1.0

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

Message 生成策略消息

func (*StrategyEndpoint) String added in v1.1.0

func (e *StrategyEndpoint) String() string

String 将策略端点转换为字符串

type StrategyEvent added in v1.1.38

type StrategyEvent struct {
	// 策略类型
	StrategyType vobj.StrategyType `json:"strategyType,omitempty"`
	// 团队ID
	TeamID uint32 `json:"teamId,omitempty"`
	// 接收者 (告警组ID列表)
	ReceiverGroupIDs []uint32 `json:"receiverGroupIDs,omitempty"`
	// 策略ID
	ID uint32 `json:"id,omitempty"`
	// 策略等级ID
	LevelID uint32 `json:"levelId,omitempty"`
	// 策略名称
	Alert string `json:"alert,omitempty"`
	// 策略语句
	Expr string `json:"expr,omitempty"`
	// 阈值
	Threshold string `json:"threshold,omitempty"`
	// 判断条件
	Condition vobj.MQCondition `json:"condition,omitempty"`
	// 数据类型
	DataType vobj.MQDataType `json:"dataType,omitempty"`
	// 数据 Key
	DataKey string `json:"dataKey,omitempty"`
	// 数据源
	Datasource []*MQDatasource `json:"datasource,omitempty"`
	// 策略状态
	Status vobj.Status `json:"status,omitempty"`
	// 策略标签
	Labels *vobj.Labels `json:"labels,omitempty"`
	// 策略注解
	Annotations *vobj.Annotations `json:"annotations,omitempty"`
	// contains filtered or unexported fields
}

StrategyEvent 事件策略明细

func (*StrategyEvent) BuilderAlarmBaseInfo added in v1.1.38

func (s *StrategyEvent) BuilderAlarmBaseInfo() *Alarm

BuilderAlarmBaseInfo 实现 IStrategy 接口

func (*StrategyEvent) Eval added in v1.1.38

Eval 实现 IStrategy 接口

func (*StrategyEvent) GetAnnotations added in v1.1.38

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

GetAnnotations 实现 IStrategy 接口

func (*StrategyEvent) GetDatasource added in v1.1.38

func (s *StrategyEvent) GetDatasource() []*MQDatasource

GetDatasource 获取数据源

func (*StrategyEvent) GetInterval added in v1.1.38

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

GetInterval 实现 IStrategy 接口

func (*StrategyEvent) GetLabelNotices added in v1.1.38

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

GetLabelNotices 实现 IStrategy 接口

func (*StrategyEvent) GetReceiverGroupIDs added in v1.1.38

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

GetReceiverGroupIDs 实现 IStrategy 接口

func (*StrategyEvent) GetStatus added in v1.1.38

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

GetStatus 实现 IStrategy 接口

func (*StrategyEvent) GetTeamID added in v1.1.38

func (s *StrategyEvent) GetTeamID() uint32

GetTeamID 实现 IStrategy 接口

func (*StrategyEvent) GetTopic added in v1.1.38

func (s *StrategyEvent) GetTopic() string

GetTopic 获取主题

func (*StrategyEvent) Index added in v1.1.38

func (s *StrategyEvent) Index() string

Index 实现 watch.Indexer 接口

func (*StrategyEvent) IsCompletelyMeet added in v1.1.38

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

IsCompletelyMeet 实现 IStrategy 接口

func (*StrategyEvent) Message added in v1.1.38

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

Message 实现 watch.Message 接口

func (*StrategyEvent) SetValue added in v1.1.38

func (s *StrategyEvent) SetValue(msg *mq.Msg) IStrategyEvent

SetValue 设置数据

func (*StrategyEvent) String added in v1.1.38

func (s *StrategyEvent) String() string

String 实现 fmt.Stringer 接口

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"`
	// 判断条件
	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

BuilderAlarmBaseInfo 生成告警基础信息

func (*StrategyMetric) Eval added in v1.1.0

Eval 评估策略

func (*StrategyMetric) GetAnnotations added in v1.1.0

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

GetAnnotations 获取策略注解

func (*StrategyMetric) GetInterval added in v1.1.0

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

GetInterval 获取执行频率

func (*StrategyMetric) GetLabelNotices added in v1.1.0

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

GetLabelNotices 获取自定义接收者匹配对象

func (*StrategyMetric) GetReceiverGroupIDs added in v1.1.0

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

GetReceiverGroupIDs 获取接收者组ID列表

func (*StrategyMetric) GetStatus added in v1.1.0

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

GetStatus 获取策略状态

func (*StrategyMetric) GetTeamID added in v1.1.0

func (s *StrategyMetric) GetTeamID() uint32

GetTeamID 获取团队ID

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

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

BuilderAlarmBaseInfo 生成告警基础信息

func (*StrategyPing) Eval added in v1.1.0

Eval 评估策略

func (*StrategyPing) GetAnnotations added in v1.1.0

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

GetAnnotations 获取策略注解

func (*StrategyPing) GetInterval added in v1.1.0

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

GetInterval 获取执行频率

func (*StrategyPing) GetLabelNotices added in v1.1.0

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

GetLabelNotices 获取自定义接收者匹配对象

func (*StrategyPing) GetReceiverGroupIDs added in v1.1.0

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

GetReceiverGroupIDs 获取接收者组ID列表

func (*StrategyPing) GetStatus added in v1.1.0

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

GetStatus 获取策略状态

func (*StrategyPing) GetTeamID added in v1.1.0

func (s *StrategyPing) GetTeamID() uint32

GetTeamID 获取团队ID

func (*StrategyPing) Index added in v1.1.0

func (s *StrategyPing) Index() string

Index 生成策略索引

func (*StrategyPing) IsCompletelyMeet added in v1.1.0

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

IsCompletelyMeet 是否完全满足策略条件

func (*StrategyPing) Message added in v1.1.0

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

Message 生成策略消息

func (*StrategyPing) String added in v1.1.0

func (s *StrategyPing) String() string

String 将策略转换为字符串

Jump to

Keyboard shortcuts

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