Documentation ¶
Index ¶
- Constants
- func CheckQueryExprNamespace(expr, namespace string) error
- func GetBaseAlertmanagerConfig(namespace, name string) *v1alpha1.AlertmanagerConfig
- func GetBasePrometheusRule(namespace, name string) *monitoringv1.PrometheusRule
- func MutateLoggingAlert(req *LoggingAlertRule) error
- func MutateMonitorAlert(req *MonitorAlertRule, tplGetter templates.TplGetter) error
- type Action
- type AlertLevel
- type AlertReceiver
- type AlertRule
- type AlertRuleList
- type BaseAlertResource
- func (base *BaseAlertResource) GetAlertReceiverMap() (map[string][]AlertReceiver, error)
- func (base *BaseAlertResource) GetInhibitRuleMap() map[string]v1alpha1.InhibitRule
- func (base *BaseAlertResource) GetSilenceMap() map[string]alertmanagertypes.Silence
- func (base *BaseAlertResource) Update(alertrules AlertRuleList[AlertRule], act Action) error
- func (base *BaseAlertResource) UpdateInhibitRules(alertrules AlertRuleList[AlertRule])
- func (base *BaseAlertResource) UpdateReceivers(alertrules AlertRuleList[AlertRule], act Action) error
- func (base *BaseAlertResource) UpdateRoutes(alertrules AlertRuleList[AlertRule])
- type BaseAlertRule
- func (r *BaseAlertRule) CheckAndModify() error
- func (r BaseAlertRule) GetAlertLevels() []AlertLevel
- func (r BaseAlertRule) GetInhibitLabels() []string
- func (r BaseAlertRule) GetName() string
- func (r BaseAlertRule) GetNamespace() string
- func (r BaseAlertRule) GetReceivers() []AlertReceiver
- func (r *BaseAlertRule) IsExtraAlert() bool
- func (b *BaseAlertRule) SetChannelStatus()
- type ChannelStatus
- type DependencyLink
- type KeyValue
- type Log
- type LoggingAlertRule
- type LogqlGenerator
- type MonitorAlertRule
- type ObserveClient
- func (c *ObserveClient) CommitRawLoggingAlertResource(ctx context.Context, raw *RawLoggingAlertRule) error
- func (c *ObserveClient) CommitRawMonitorAlertResource(ctx context.Context, raw *RawMonitorAlertResource) error
- func (c *ObserveClient) CreateOrUpdateAlertEmailSecret(ctx context.Context, namespace string, receivers []AlertReceiver) error
- func (c *ObserveClient) CreateOrUpdateSilenceIfNotExist(ctx context.Context, info models.AlertInfo) error
- func (c *ObserveClient) DeleteSilenceIfExist(ctx context.Context, info models.AlertInfo) error
- func (c *ObserveClient) GetOrCreateAlertmanagerConfig(ctx context.Context, namespace, name string) (*monitoringv1alpha1.AlertmanagerConfig, error)
- func (c *ObserveClient) GetOrCreatePrometheusRule(ctx context.Context, namespace, name string) (*monitoringv1.PrometheusRule, error)
- func (c *ObserveClient) GetRawLoggingAlertResource(ctx context.Context, namespace string) (*RawLoggingAlertRule, error)
- func (c *ObserveClient) GetRawMonitorAlertResource(ctx context.Context, namespace, name string, tplGetter templates.TplGetter) (*RawMonitorAlertResource, error)
- func (c ObserveClient) GetTrace(ctx context.Context, traceID string) (*Trace, error)
- func (c *ObserveClient) ListLoggingAlertRules(ctx context.Context, namespace string, hasDetail bool) ([]LoggingAlertRule, error)
- func (c *ObserveClient) ListMonitorAlertRules(ctx context.Context, namespace string, hasDetail bool, ...) ([]MonitorAlertRule, error)
- func (c *ObserveClient) ListSilences(ctx context.Context, labels map[string]string, commentPrefix string) ([]alertmanagertypes.Silence, error)
- func (c ObserveClient) SearchTrace(ctx context.Context, service string, start, end time.Time, ...) ([]Trace, error)
- type Operation
- type Process
- type ProcessID
- type RawLoggingAlertRule
- type RawMonitorAlertResource
- type Reference
- type ReferenceType
- type Span
- type SpanID
- type Trace
- type TraceID
- type ValueType
Constants ¶
const ( // ChildOf means a span is the child of another span ChildOf ReferenceType = "CHILD_OF" // FollowsFrom means a span follows from another span FollowsFrom ReferenceType = "FOLLOWS_FROM" // StringType indicates a string value stored in KeyValue StringType ValueType = "string" // BoolType indicates a Boolean value stored in KeyValue BoolType ValueType = "bool" // Int64Type indicates a 64bit signed integer value stored in KeyValue Int64Type ValueType = "int64" // Float64Type indicates a 64bit float value stored in KeyValue Float64Type ValueType = "float64" // BinaryType indicates an arbitrary byte array stored in KeyValue BinaryType ValueType = "binary" )
const ( LoggingAlertRuleCMName = "kubegems-loki-rules" LokiRecordingRulesKey = "kubegems-loki-recording-rules.yaml" )
Variables ¶
This section is empty.
Functions ¶
func CheckQueryExprNamespace ¶
func GetBaseAlertmanagerConfig ¶
func GetBaseAlertmanagerConfig(namespace, name string) *v1alpha1.AlertmanagerConfig
func GetBasePrometheusRule ¶
func GetBasePrometheusRule(namespace, name string) *monitoringv1.PrometheusRule
func MutateLoggingAlert ¶
func MutateLoggingAlert(req *LoggingAlertRule) error
func MutateMonitorAlert ¶
func MutateMonitorAlert(req *MonitorAlertRule, tplGetter templates.TplGetter) error
Types ¶
type AlertLevel ¶
type AlertReceiver ¶
type AlertReceiver struct { AlertChannel *models.AlertChannel `json:"alertChannel"` Interval string `json:"interval"` // 分组间隔 RawReceiver v1alpha1.Receiver `json:"-"` ChannelStatus `json:"channelStatus"` }
func (*AlertReceiver) SetChannelAndStatus ¶ added in v1.22.1
func (r *AlertReceiver) SetChannelAndStatus(getter channels.ChannelGetter)
type AlertRule ¶
type AlertRule interface { GetNamespace() string GetName() string GetInhibitLabels() []string GetAlertLevels() []AlertLevel GetReceivers() []AlertReceiver }
type AlertRuleList ¶
type AlertRuleList[T AlertRule] []T
func (AlertRuleList[T]) ToAlertRuleList ¶
func (l AlertRuleList[T]) ToAlertRuleList() []AlertRule
type BaseAlertResource ¶
type BaseAlertResource struct { AMConfig *v1alpha1.AlertmanagerConfig Silences []alertmanagertypes.Silence ChannelGetter channels.ChannelGetter }
func (*BaseAlertResource) GetAlertReceiverMap ¶
func (base *BaseAlertResource) GetAlertReceiverMap() (map[string][]AlertReceiver, error)
func (*BaseAlertResource) GetInhibitRuleMap ¶
func (base *BaseAlertResource) GetInhibitRuleMap() map[string]v1alpha1.InhibitRule
func (*BaseAlertResource) GetSilenceMap ¶
func (base *BaseAlertResource) GetSilenceMap() map[string]alertmanagertypes.Silence
func (*BaseAlertResource) Update ¶
func (base *BaseAlertResource) Update(alertrules AlertRuleList[AlertRule], act Action) error
func (*BaseAlertResource) UpdateInhibitRules ¶
func (base *BaseAlertResource) UpdateInhibitRules(alertrules AlertRuleList[AlertRule])
func (*BaseAlertResource) UpdateReceivers ¶
func (base *BaseAlertResource) UpdateReceivers(alertrules AlertRuleList[AlertRule], act Action) error
func (*BaseAlertResource) UpdateRoutes ¶
func (base *BaseAlertResource) UpdateRoutes(alertrules AlertRuleList[AlertRule])
type BaseAlertRule ¶
type BaseAlertRule struct { Namespace string `json:"namespace"` Name string `json:"name"` Expr string `json:"expr"` // promql/logql表达式,不能包含比较运算符(<, <=, >, >=, ==) For string `json:"for"` // 持续时间, eg. 10s, 1m, 1h Message string `json:"message"` // 告警消息,若为空后端自动填充 InhibitLabels []string `json:"inhibitLabels"` // 如果有多个告警级别,需要配置告警抑制的labels AlertLevels []AlertLevel `json:"alertLevels"` // 告警级别 Receivers []AlertReceiver `json:"receivers"` // 接收器 IsOpen bool `json:"isOpen"` // 是否启用 State string `json:"state"` // 状态 ChannelStatus `json:"channelStatus"` }
func (*BaseAlertRule) CheckAndModify ¶
func (r *BaseAlertRule) CheckAndModify() error
func (BaseAlertRule) GetAlertLevels ¶
func (r BaseAlertRule) GetAlertLevels() []AlertLevel
func (BaseAlertRule) GetInhibitLabels ¶
func (r BaseAlertRule) GetInhibitLabels() []string
func (BaseAlertRule) GetName ¶
func (r BaseAlertRule) GetName() string
func (BaseAlertRule) GetNamespace ¶
func (r BaseAlertRule) GetNamespace() string
func (BaseAlertRule) GetReceivers ¶
func (r BaseAlertRule) GetReceivers() []AlertReceiver
func (*BaseAlertRule) IsExtraAlert ¶
func (r *BaseAlertRule) IsExtraAlert() bool
IsExtraAlert 用于记录额外信息 如在生成监控的amcfg时,避免忽视日志的route
func (*BaseAlertRule) SetChannelStatus ¶ added in v1.22.1
func (b *BaseAlertRule) SetChannelStatus()
type ChannelStatus ¶ added in v1.22.1
type ChannelStatus int
const ( StatusNormal ChannelStatus = iota // 告警渠道正常 StatusChanged // 告警渠道被修改过,现在数据不一致 StatusLost // 告警渠道丢失(被删除) )
type DependencyLink ¶ added in v1.23.0
type DependencyLink struct { Parent string `json:"parent"` Child string `json:"child"` CallCount uint64 `json:"callCount"` }
DependencyLink shows dependencies between services
type KeyValue ¶ added in v1.23.0
type KeyValue struct { Key string `json:"key"` Type ValueType `json:"type,omitempty"` Value interface{} `json:"value"` }
KeyValue is a key-value pair with typed value.
type LoggingAlertRule ¶
type LoggingAlertRule struct { LogqlGenerator *LogqlGenerator `json:"logqlGenerator"` BaseAlertRule `json:",inline"` RealTimeAlerts []*promv1.Alert `json:"realTimeAlerts,omitempty"` // 实时告警 Origin string `json:"origin,omitempty"` // 原始的prometheusrule }
type LogqlGenerator ¶
type LogqlGenerator struct { Duration string `json:"duration"` // 时间范围 Match string `json:"match"` // 正则匹配的字符串 LabelPairs map[string]string `json:"labelpairs,omitempty"` // 标签键值对 }
func (*LogqlGenerator) IsEmpty ¶
func (g *LogqlGenerator) IsEmpty() bool
func (*LogqlGenerator) ToLogql ¶
func (g *LogqlGenerator) ToLogql(namespace string) string
type MonitorAlertRule ¶
type MonitorAlertRule struct { PromqlGenerator *prometheus.PromqlGenerator `json:"promqlGenerator"` BaseAlertRule `json:",inline"` RealTimeAlerts []*promv1.Alert `json:"realTimeAlerts,omitempty"` // 实时告警 Origin string `json:"origin,omitempty"` // 原始的prometheusrule Source string `json:"source"` // 来自哪个prometheusrule TplLost bool `json:"tplLost"` // 监控模板是否丢失 }
type ObserveClient ¶
func (*ObserveClient) CommitRawLoggingAlertResource ¶
func (c *ObserveClient) CommitRawLoggingAlertResource(ctx context.Context, raw *RawLoggingAlertRule) error
func (*ObserveClient) CommitRawMonitorAlertResource ¶
func (c *ObserveClient) CommitRawMonitorAlertResource(ctx context.Context, raw *RawMonitorAlertResource) error
func (*ObserveClient) CreateOrUpdateAlertEmailSecret ¶
func (c *ObserveClient) CreateOrUpdateAlertEmailSecret(ctx context.Context, namespace string, receivers []AlertReceiver) error
func (*ObserveClient) CreateOrUpdateSilenceIfNotExist ¶
func (c *ObserveClient) CreateOrUpdateSilenceIfNotExist(ctx context.Context, info models.AlertInfo) error
use for blacklist
func (*ObserveClient) DeleteSilenceIfExist ¶
use for blacklist
func (*ObserveClient) GetOrCreateAlertmanagerConfig ¶
func (c *ObserveClient) GetOrCreateAlertmanagerConfig(ctx context.Context, namespace, name string) (*monitoringv1alpha1.AlertmanagerConfig, error)
func (*ObserveClient) GetOrCreatePrometheusRule ¶
func (c *ObserveClient) GetOrCreatePrometheusRule(ctx context.Context, namespace, name string) (*monitoringv1.PrometheusRule, error)
func (*ObserveClient) GetRawLoggingAlertResource ¶
func (c *ObserveClient) GetRawLoggingAlertResource(ctx context.Context, namespace string) (*RawLoggingAlertRule, error)
func (*ObserveClient) GetRawMonitorAlertResource ¶
func (c *ObserveClient) GetRawMonitorAlertResource(ctx context.Context, namespace, name string, tplGetter templates.TplGetter) (*RawMonitorAlertResource, error)
GetRawMonitorAlertResource get specified namespace's alert
func (*ObserveClient) ListLoggingAlertRules ¶
func (c *ObserveClient) ListLoggingAlertRules(ctx context.Context, namespace string, hasDetail bool) ([]LoggingAlertRule, error)
func (*ObserveClient) ListMonitorAlertRules ¶
func (c *ObserveClient) ListMonitorAlertRules(ctx context.Context, namespace string, hasDetail bool, tplGetter templates.TplGetter) ([]MonitorAlertRule, error)
func (*ObserveClient) ListSilences ¶
func (c *ObserveClient) ListSilences(ctx context.Context, labels map[string]string, commentPrefix string) ([]alertmanagertypes.Silence, error)
type Operation ¶ added in v1.23.0
Operation defines the data in the operation response when query operation by service and span kind
type ProcessID ¶ added in v1.23.0
type ProcessID string
ProcessID is a hashed value of the Process struct that is unique within the trace.
type RawLoggingAlertRule ¶
type RawLoggingAlertRule struct { Base *BaseAlertResource *corev1.ConfigMap *rulefmt.RuleGroups }
func (*RawLoggingAlertRule) ModifyLoggingAlertRule ¶
func (raw *RawLoggingAlertRule) ModifyLoggingAlertRule(r LoggingAlertRule, act Action) error
func (*RawLoggingAlertRule) ToAlerts ¶
func (raw *RawLoggingAlertRule) ToAlerts(hasDetail bool) (AlertRuleList[LoggingAlertRule], error)
type RawMonitorAlertResource ¶
type RawMonitorAlertResource struct { Base *BaseAlertResource *monitoringv1.PrometheusRule TplGetter templates.TplGetter }
里面资源的namespace必须相同
func (*RawMonitorAlertResource) ModifyAlertRule ¶
func (raw *RawMonitorAlertResource) ModifyAlertRule(newAlertRule MonitorAlertRule, act Action) error
所有alertrule都是一个namespace
func (*RawMonitorAlertResource) ToAlerts ¶
func (raw *RawMonitorAlertResource) ToAlerts(hasDetail bool) (AlertRuleList[MonitorAlertRule], error)
默认认为namespace全部一致
type Reference ¶ added in v1.23.0
type Reference struct { RefType ReferenceType `json:"refType"` TraceID TraceID `json:"traceID"` SpanID SpanID `json:"spanID"` }
Reference is a reference from one span to another
type ReferenceType ¶ added in v1.23.0
type ReferenceType string
ReferenceType is the reference type of one span to another
type Span ¶ added in v1.23.0
type Span struct { TraceID TraceID `json:"traceID"` SpanID SpanID `json:"spanID"` ParentSpanID SpanID `json:"parentSpanID,omitempty"` // deprecated Flags uint32 `json:"flags,omitempty"` OperationName string `json:"operationName"` References []Reference `json:"references"` StartTime uint64 `json:"startTime"` // microseconds since Unix epoch Duration uint64 `json:"duration"` // microseconds Tags []KeyValue `json:"tags"` Logs []Log `json:"logs"` ProcessID ProcessID `json:"processID,omitempty"` Process *Process `json:"process,omitempty"` Warnings []string `json:"warnings"` }
Span is a span denoting a piece of work in some infrastructure When converting to UI model, ParentSpanID and Process should be dereferenced into References and ProcessID, respectively. When converting to ES model, ProcessID and Warnings should be omitted. Even if included, ES with dynamic settings off will automatically ignore unneeded fields.
type Trace ¶ added in v1.23.0
type Trace struct { TraceID TraceID `json:"traceID"` Spans []Span `json:"spans"` Processes map[ProcessID]Process `json:"processes"` Warnings []string `json:"warnings"` }
Trace is a list of spans