Documentation
¶
Index ¶
- Constants
- Variables
- func FindReceiver(aconfig *v1alpha1.AlertmanagerConfig, targetName string) bool
- func IsReceiverInUse(route *v1alpha1.Route, receiver v1alpha1.Receiver) bool
- func IsValidPromqlTplName(scope, resource, rule string) error
- func RealTimeAlertKey(namespace, name string) string
- func SplitQueryExpr(ql string) (query, op, value string, hasOp bool)
- type Alert
- type ExporterOptions
- type MetricGraph
- type MonitorGraphs
- type PromqlGenerator
- type RealTimeAlertRule
- type UnitValue
- type WebhookAlert
Constants ¶
View Source
const ( AlertNamespaceLabel = "gems_namespace" AlertNameLabel = "gems_alertname" // 用于从告警中获取告警资源 AlertFromLabel = "gems_alert_from" // 告警来自哪里,logging/monitor AlertPromqlTpl = "gems_alert_tpl" // eg. platform.cluster.cpuUsageTotal AlertTypeMonitor = "monitor" AlertTypeLogging = "logging" SeverityLabel = "severity" SeverityError = "error" // 错误 SeverityCritical = "critical" // 严重 ExprJsonAnnotationKey = "gems_expr_json" MessageAnnotationsKey = "message" ValueAnnotationKey = "value" ValueAnnotationExpr = `{{ $value | printf "%.1f" }}` AlertRuleKeyFormat = "gems-%s-%s" AlertClusterKey = "cluster" // 告警消息发送范围 AlertScopeLabel = "gems_alert_scope" ScopeSystemAdmin = "system-admin" // 系统管理员 ScopeSystemUser = "system-user" // 所有用户 ScopeNormal = "normal" // 普通租户用户 SilenceCommentForBlackListPrefix = "fingerprint-" SilenceCommentForAlertrulePrefix = "silence for" // 全局告警命名空间,非此命名空间强制加上namespace筛选 GlobalAlertNamespace = gems.NamespaceMonitor // namespace PromqlNamespaceKey = "namespace" // prometheusrule and alertmanagerconfigname DefaultAlertCRDName = "kubegems-default-monitor-alert-rule" )
Variables ¶
View Source
var ( NullReceiverName = "null" NullReceiver = v1alpha1.Receiver{Name: NullReceiverName} )
View Source
var ( // 单位表 UnitValueMap = map[string]UnitValue{ "B": defaultUnitValue, "KB": {Op: "/", Value: "1024"}, "MB": {Op: "/", Value: "(1024 * 1024)"}, "GB": {Op: "/", Value: "(1024 * 1024 * 1024)"}, "TB": {Op: "/", Value: "(1024 * 1024 * 1024 * 1024)"}, "PB": {Op: "/", Value: "(1024 * 1024 * 1024 * 1024 * 1024)"}, "B/s": defaultUnitValue, "KB/s": {Op: "/", Value: "1024"}, "MB/s": {Op: "/", Value: "(1024 * 1024)"}, "GB/s": {Op: "/", Value: "(1024 * 1024 * 1024)"}, "TB/s": {Op: "/", Value: "(1024 * 1024 * 1024 * 1024)"}, "PB/s": {Op: "/", Value: "(1024 * 1024 * 1024 * 1024 * 1024)"}, "us": {Op: "*", Value: "(1000 * 1000)"}, "ms": {Op: "*", Value: "1000"}, "s": defaultUnitValue, "m": {Op: "/", Value: "60"}, "h": {Op: "/", Value: "(60 * 60)"}, "d": {Op: "/", Value: "(24 * 60 * 60)"}, "w": {Op: "/", Value: "(7 * 24 * 60 * 60)"}, "0.0-1.0": {Op: "*", Value: "100", Show: "%"}, "0-100": {Show: "%"}, } )
Functions ¶
func FindReceiver ¶ added in v1.22.0
func FindReceiver(aconfig *v1alpha1.AlertmanagerConfig, targetName string) bool
func IsReceiverInUse ¶ added in v1.22.0
func IsValidPromqlTplName ¶ added in v1.22.0
func RealTimeAlertKey ¶
func SplitQueryExpr ¶
Types ¶
type ExporterOptions ¶
type ExporterOptions struct {
Listen string `json:"listen,omitempty" description:"listen address"`
}
func DefaultExporterOptions ¶
func DefaultExporterOptions() *ExporterOptions
type MetricGraph ¶ added in v1.22.0
type MetricGraph struct { // graph名 Name string `json:"name"` // 查询目标 *PromqlGenerator `json:"promqlGenerator"` Expr string `json:"expr"` Unit string `json:"unit"` }
type MonitorGraphs ¶ added in v1.22.0
type MonitorGraphs []MetricGraph
func (MonitorGraphs) GormDataType ¶ added in v1.22.0
func (g MonitorGraphs) GormDataType() string
func (*MonitorGraphs) Scan ¶ added in v1.22.0
func (g *MonitorGraphs) Scan(src interface{}) error
type PromqlGenerator ¶
type PromqlGenerator struct { Scope string `json:"scope"` // scope Resource string `json:"resource"` // 告警资源, eg. node、pod Rule string `json:"rule"` // 告警规则名, eg. cpuUsage、memoryUsagePercent Unit string `json:"unit"` // 单位 LabelPairs map[string]string `json:"labelpairs,omitempty"` // 标签键值对 UnitValue UnitValue `json:"-"` Tpl *templates.PromqlTpl `json:"-"` }
func (*PromqlGenerator) Notpl ¶ added in v1.22.0
func (g *PromqlGenerator) Notpl() bool
func (*PromqlGenerator) SetTpl ¶ added in v1.22.0
func (g *PromqlGenerator) SetTpl(f templates.TplGetter) error
func (*PromqlGenerator) ToPromql ¶
func (g *PromqlGenerator) ToPromql(namespace string) (string, error)
func (*PromqlGenerator) TplString ¶ added in v1.22.0
func (g *PromqlGenerator) TplString() string
type RealTimeAlertRule ¶
type RealTimeAlertRule struct { Name string `json:"name"` // Query string `json:"query"` // Duration float64 `json:"duration"` // Labels model.LabelSet `json:"labels"` // Annotations model.LabelSet `json:"annotations"` Alerts []*v1.Alert `json:"alerts"` // Health v1.RuleHealth `json:"health"` // LastError string `json:"lastError,omitempty"` // EvaluationTime float64 `json:"evaluationTime"` // LastEvaluation time.Time `json:"lastEvaluation"` State string `json:"state"` }
func (*RealTimeAlertRule) Len ¶
func (r *RealTimeAlertRule) Len() int
func (*RealTimeAlertRule) Less ¶
func (r *RealTimeAlertRule) Less(i, j int) bool
func (*RealTimeAlertRule) Swap ¶
func (r *RealTimeAlertRule) Swap(i, j int)
type WebhookAlert ¶ added in v1.22.0
type WebhookAlert struct { Receiver string `json:"receiver"` Status string `json:"status"` Alerts []Alert `json:"alerts"` GroupLabels map[string]string `json:"groupLabels"` CommonLabels map[string]string `json:"commonLabels"` CommonAnnotations map[string]string `json:"commonAnnotations"` ExternalURL string `json:"externalURL"` Version string `json:"version"` GroupKey string `json:"groupKey"` TruncatedAlerts int64 `json:"truncatedAlerts"` }
func (*WebhookAlert) FingerprintMap ¶ added in v1.22.0
func (w *WebhookAlert) FingerprintMap() map[string][]Alert
Click to show internal directories.
Click to hide internal directories.