alert

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package alert provides Prometheus alerts, queries and access to Thanos and AlertManager stores.

Class

There is a single class `alert:alert`.

Object

An alert object is represented by this Go type. Rules starting from an alert should use the capitalized Go field names rather than the lowercase JSON names. Object

Query

A JSON map of string names to string values, matched against alert labels, for example:

alert:alert:{"alertname":"KubeStatefulSetReplicasMismatch","container":"kube-rbac-proxy-main","namespace":"openshift-logging"}

Store

A client of Prometheus and/or AlertManager. Store configuration:

domain: alert
metrics: PROMETHEUS_URL
alertmanager: ALERTMANAGER_URL

Either or both of `metrics` or `alertmanager` may be present.

Index

Constants

View Source
const (
	StoreKeyMetrics      = "metrics"
	StoreKeyAlertmanager = "alertmanager"
)

Variables

View Source
var Domain = domain{}

Functions

func NewStore

func NewStore(alertmanagerURL *url.URL, prometheusURL *url.URL, hc *http.Client) (korrel8r.Store, error)

NewStore creates a new store client for a Prometheus URL.

Types

type Class

type Class struct{}

Class is represents any Prometheus alert. There is only a single class, named "alert".

func (Class) Description added in v0.1.2

func (c Class) Description() string

func (Class) Domain

func (c Class) Domain() korrel8r.Domain

func (Class) ID

func (c Class) ID(o korrel8r.Object) any

func (Class) Name added in v0.1.2

func (c Class) Name() string

func (Class) New

func (c Class) New() korrel8r.Object

func (Class) Preview

func (c Class) Preview(o korrel8r.Object) string

func (Class) String

func (c Class) String() string

type Object

type Object struct {
	// Common fields.
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	Status      string            `json:"status"` // inactive|pending|firing|suppressed
	StartsAt    time.Time         `json:"startsAt"`

	// Prometheus fields.
	Value       string `json:"value"`
	Expression  string `json:"expression"`
	Fingerprint string `json:"fingerprint"`

	// Alertmanager fields.
	EndsAt       time.Time  `json:"endsAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	Receivers    []Receiver `json:"receivers"`
	InhibitedBy  []string   `json:"inhibitedBy"`
	SilencedBy   []string   `json:"silencedBy"`
	GeneratorURL string     `json:"generatorURL"`
}

Object is represented by the JSON serialization the following type.

type Query

type Query map[string]string

Query is a map of label name:value pairs for matching alerts, serialized as JSON.

func (Query) Class

func (q Query) Class() korrel8r.Class

func (Query) Data added in v0.6.0

func (q Query) Data() string

func (Query) String

func (q Query) String() string

type Receiver

type Receiver struct {
	Name string `json:"name"`
}

Receiver is a named receiver, part of Object.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a client of Prometheus and AlertManager.

func (Store) Domain

func (Store) Domain() korrel8r.Domain

func (Store) Get

func (s Store) Get(ctx context.Context, query korrel8r.Query, c *korrel8r.Constraint, result korrel8r.Appender) error

Jump to

Keyboard shortcuts

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