alertmanager

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package alertmanager defines structures and primitives to support Alertmanager's webhook API.

Shamelessly ripped from github.com/prometheus/alertmanager/template/template.go to avoid a huge dependency tree,

Index

Constants

View Source
const (
	// AlertNameLabel is the name of the label containing the an alert's name.
	AlertNameLabel = "alertname"

	// AlertResolved is the status value for a resolved alert.
	AlertResolved = "resolved"
)

Variables

View Source
var (
	// AlertFiring is the status value for a firing alert.
	AlertFiring string = "firing"
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Status       string    `json:"status"`
	Labels       KV        `json:"labels"`
	Annotations  KV        `json:"annotations"`
	StartsAt     time.Time `json:"startsAt"`
	EndsAt       time.Time `json:"endsAt"`
	GeneratorURL string    `json:"generatorURL"`
}

Alert holds one alert for notification templates.

type Alerts

type Alerts []Alert

Alerts is a list of Alert objects.

func (Alerts) Firing

func (as Alerts) Firing() []Alert

Firing returns the subset of alerts that are firing.

type Data

type Data struct {
	// The protocol version.
	Version  string `json:"version"`
	GroupKey string `json:"groupKey"`

	Receiver string `json:"receiver"`
	Status   string `json:"status"`
	Alerts   Alerts `json:"alerts"`

	GroupLabels       KV `json:"groupLabels"`
	CommonLabels      KV `json:"commonLabels"`
	CommonAnnotations KV `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

Data is the data passed to notification templates and webhook pushes.

End-users should not be exposed to Go's type system, as this will confuse them and prevent simple things like simple equality checks to fail. Map everything to float64/string.

type KV

type KV map[string]string

KV is a set of key/value string pairs.

func (KV) Names

func (kv KV) Names() []string

Names returns the names of the label names in the LabelSet.

func (KV) Remove

func (kv KV) Remove(keys []string) KV

Remove returns a copy of the key/value set without the given keys.

func (KV) SortedPairs

func (kv KV) SortedPairs() Pairs

SortedPairs returns a sorted list of key/value pairs.

func (KV) Values

func (kv KV) Values() []string

Values returns a list of the values in the LabelSet.

type Pair

type Pair struct {
	Name, Value string
}

Pair is a key/value string pair.

type Pairs

type Pairs []Pair

Pairs is a list of key/value string pairs.

func (Pairs) Names

func (ps Pairs) Names() []string

Names returns a list of names of the pairs.

func (Pairs) Values

func (ps Pairs) Values() []string

Values returns a list of values of the pairs.

Jump to

Keyboard shortcuts

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