metrics

package
v0.6.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Building promethues / cortex alerting rules

Index

Constants

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"

Variables

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 KubeStates = []string{"Pending", "Running", "Succeeded", "Failed", "Unknown"}

Functions

func MergeLabels

func MergeLabels(ms ...map[string]string) map[string]string

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.Rule, 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 NewKubeStateRule

func NewKubeStateRule(
	objType string,
	objName string,
	namespace string,
	podState string,
	forDuration string,
	annotations map[string]string,
) (*AlertingRule, error)

func (*AlertingRule) And

func (*AlertingRule) AsRuleFmt

func (a *AlertingRule) AsRuleFmt() *rulefmt.Rule

func (*AlertingRule) Build

func (a *AlertingRule) Build(id string) (*rulefmt.Rule, error)

func (*AlertingRule) IfForSecondsThen

func (a *AlertingRule) IfForSecondsThen(other *AlertingRule, seconds time.Duration) AlertRuleBuilder

func (*AlertingRule) IfNotForSecondsThen

func (a *AlertingRule) IfNotForSecondsThen(other *AlertingRule, seconds time.Duration) AlertRuleBuilder

func (*AlertingRule) Or

func (*AlertingRule) Validate

func (a *AlertingRule) Validate() error

Jump to

Keyboard shortcuts

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