Documentation ¶
Overview ¶
Building promethues / cortex alerting rules
Index ¶
- Constants
- Variables
- func PostProcessRuleString(inputString string) string
- func WithSloId(sloId, alertType, suffix string) string
- type AlertRuleBuilder
- type AlertingRule
- func NewCpuRule(nodeFilters map[string]*alertingv1.Cores, cpuStates []string, operation string, ...) (*AlertingRule, error)
- func NewCpuSpikeRule(nodeFilters map[string]*alertingv1.Cores, cpuStates []string, operation string, ...) (*AlertingRule, error)
- func NewFsRule(nodeFilters map[string]*alertingv1.FilesystemInfo, operation string, ...) (*AlertingRule, error)
- func NewFsSpikeRule(nodeFilters map[string]*alertingv1.FilesystemInfo, operation string, ...) (*AlertingRule, error)
- func NewKubeStateRule(objType string, objName string, namespace string, podState string, ...) (*AlertingRule, error)
- func NewMemRule(deviceFilters map[string]*alertingv1.MemoryInfo, usageTypes []string, ...) (*AlertingRule, error)
- func NewMemSpikeRule(deviceFilters map[string]*alertingv1.MemoryInfo, usageTypes []string, ...) (*AlertingRule, error)
- func (a *AlertingRule) And(other *AlertingRule) AlertRuleBuilder
- func (a *AlertingRule) AsRuleFmt() *rulefmt.RuleNode
- func (a *AlertingRule) Build(id string) (*rulefmt.RuleNode, error)
- func (a *AlertingRule) IfForSecondsThen(_ *AlertingRule, _ time.Duration) AlertRuleBuilder
- func (a *AlertingRule) IfNotForSecondsThen(_ *AlertingRule, _ time.Duration) AlertRuleBuilder
- func (a *AlertingRule) Or(other *AlertingRule) AlertRuleBuilder
- func (a *AlertingRule) Validate() error
- type Filter
- type PrometheusFilters
- func (p *PrometheusFilters) AddFilter(key string)
- func (p *PrometheusFilters) And(key string, value string)
- func (p *PrometheusFilters) Build() string
- func (p *PrometheusFilters) Equals(key string)
- func (p *PrometheusFilters) Match(key string)
- func (p *PrometheusFilters) NotEquals(key string)
- func (p *PrometheusFilters) Or(key string, value string)
Constants ¶
View Source
const CPUMatcherName = "node_cpu_seconds_total"
View Source
const CpuFilter = "cpu"
View Source
const FilesystemMatcherName = "node_filesystem_free_bytes"
View Source
const KubeMetricsIsDefinedMetricName = "kube_namespace_created"
View Source
const KubeObjMetricNameMatcher = "kube_.*_status_phase"
KubeObjMetricNameMatcher
PromQl Matcher for kube state metrics
View Source
const KubePodStatusMetricName = "kube_pod_status_phase"
View Source
const MemoryDeviceFilter = "device"
View Source
const MemoryMatcherName = "node_memory_.*_bytes"
View Source
const ModeFilter = "mode"
View Source
const NodeExportFilesystemDeviceLabel = "device"
View Source
const NodeExporterMountpointLabel = "mountpoint"
View Source
const NodeExporterNodeLabel = "instance"
View Source
const NodeFilter = "instance"
View Source
const UnlabelledNode = "unidentified_node"
Variables ¶
View Source
var CpuRuleAnnotations = map[string]string{}
View Source
var FilesystemRuleAnnotations = map[string]string{}
View Source
var KubeObjMetricCreator = template.Must(template.New("KubeObject").Parse("kube_{{.ObjType}}_status_phase"))
View Source
var KubeObjTypeExtractor = regexp.MustCompile("kube_(.*)_status_phase")
KubeObjTypeExtractor
Group 1 extracts the object type
View Source
var KubeStateAlertIdLabels = []string{}
View Source
var KubeStateAnnotations = map[string]string{}
View Source
var MemRuleAnnotations = map[string]string{}
View Source
var MemoryMatcherRegexFilter = []string{"Buffers", "Cached", "MemFree", "Slab"}
View Source
var MemoryUsageTypeExtractor = regexp.MustCompile("node_memory_(.*)_bytes")
Functions ¶
func PostProcessRuleString ¶ added in v0.6.2
Types ¶
type AlertRuleBuilder ¶
type AlertRuleBuilder interface { And(rule *AlertingRule) AlertRuleBuilder Or(rule *AlertingRule) AlertRuleBuilder IfForSecondsThen(*AlertingRule, time.Duration) AlertRuleBuilder IfNotForSecondsThen(*AlertingRule, time.Duration) AlertRuleBuilder Build(id string) (*rulefmt.RuleNode, error) }
type AlertingRule ¶
type AlertingRule struct { Alert string Expr string For model.Duration Labels map[string]string Annotations map[string]string }
AlertingRule
Wrapper around rulefmt.Rule that implements the AlertingRuleBuilder interface.
func NewCpuRule ¶ added in v0.6.2
func NewCpuRule( nodeFilters map[string]*alertingv1.Cores, cpuStates []string, operation string, expectedRatio float64, duration *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func NewCpuSpikeRule ¶ added in v0.6.2
func NewCpuSpikeRule( nodeFilters map[string]*alertingv1.Cores, cpuStates []string, operation string, expectedRatio float64, numSpikes int64, duration *durationpb.Duration, spikeWindow *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func NewFsRule ¶ added in v0.6.2
func NewFsRule( nodeFilters map[string]*alertingv1.FilesystemInfo, operation string, expectedValue float64, duration *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func NewFsSpikeRule ¶ added in v0.6.2
func NewFsSpikeRule( nodeFilters map[string]*alertingv1.FilesystemInfo, operation string, expectedValue float64, numSpikes int64, duration *durationpb.Duration, spikeWindow *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func NewKubeStateRule ¶
func NewMemRule ¶ added in v0.6.2
func NewMemRule( deviceFilters map[string]*alertingv1.MemoryInfo, usageTypes []string, operation string, expectedRatio float64, duration *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func NewMemSpikeRule ¶ added in v0.6.2
func NewMemSpikeRule( deviceFilters map[string]*alertingv1.MemoryInfo, usageTypes []string, operation string, expectedRatio float64, numSpikes int64, duration *durationpb.Duration, spikeWindow *durationpb.Duration, annotations map[string]string, ) (*AlertingRule, error)
func (*AlertingRule) And ¶
func (a *AlertingRule) And(other *AlertingRule) AlertRuleBuilder
func (*AlertingRule) AsRuleFmt ¶
func (a *AlertingRule) AsRuleFmt() *rulefmt.RuleNode
func (*AlertingRule) IfForSecondsThen ¶
func (a *AlertingRule) IfForSecondsThen(_ *AlertingRule, _ time.Duration) AlertRuleBuilder
func (*AlertingRule) IfNotForSecondsThen ¶
func (a *AlertingRule) IfNotForSecondsThen(_ *AlertingRule, _ time.Duration) AlertRuleBuilder
func (*AlertingRule) Or ¶
func (a *AlertingRule) Or(other *AlertingRule) AlertRuleBuilder
func (*AlertingRule) Validate ¶
func (a *AlertingRule) Validate() error
type PrometheusFilters ¶ added in v0.6.2
func NewPrometheusFilters ¶ added in v0.6.2
func NewPrometheusFilters() *PrometheusFilters
func (*PrometheusFilters) AddFilter ¶ added in v0.6.2
func (p *PrometheusFilters) AddFilter(key string)
func (*PrometheusFilters) And ¶ added in v0.6.2
func (p *PrometheusFilters) And(key string, value string)
func (*PrometheusFilters) Build ¶ added in v0.6.2
func (p *PrometheusFilters) Build() string
func (*PrometheusFilters) Equals ¶ added in v0.6.2
func (p *PrometheusFilters) Equals(key string)
func (*PrometheusFilters) Match ¶ added in v0.6.2
func (p *PrometheusFilters) Match(key string)
func (*PrometheusFilters) NotEquals ¶ added in v0.6.2
func (p *PrometheusFilters) NotEquals(key string)
func (*PrometheusFilters) Or ¶ added in v0.6.2
func (p *PrometheusFilters) Or(key string, value string)
Click to show internal directories.
Click to hide internal directories.