alertmanager

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package alertmanager implements a very simple alertmanager client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Parent       *Message          `json:"-"`
	Status       string            `json:"status"`
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     time.Time         `json:"startsAt"`
	EndsAt       time.Time         `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
}

func NewAlert

func NewAlert() Alert

func (*Alert) GetAnnotation

func (a *Alert) GetAnnotation(key string) (value string, ok bool)

GetAnnotation gets an annotation from an alert. It will fetch annotations in Alert.Annotations with fallback to Parent.CommonAnnotations for you.

func (*Alert) GetAnnotationDefault

func (a *Alert) GetAnnotationDefault(key, def string) string

GetAnnotationDefault gets an annotation from an alert, returning a default if it isn't present.

func (*Alert) GetAnnotations

func (a *Alert) GetAnnotations() map[string]string

GetAnnotations returns a map of all the annotations on an alert.

func (*Alert) GetLabel

func (a *Alert) GetLabel(key string) (value string, ok bool)

GetLabel gets a label from an alert. It will fetch labels in Alert.Label with fallback to Parent.CommonLabels and Parent.GroupLabels for you.

func (*Alert) GetLabelDefault

func (a *Alert) GetLabelDefault(key, def string) string

GetLabelDefault gets a label from an alert, returning a default if it isn't present.

func (*Alert) GetLabels

func (a *Alert) GetLabels() map[string]string

GetLabels returns a map of all the labels on an alert.

type Client

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

func NewClient

func NewClient(baseURL *url.URL) *Client

func (*Client) SendAlerts

func (c *Client) SendAlerts(ctx context.Context, alerts []Alert) error

type Message

type Message struct {
	Version           string            `json:"version"`
	GroupKey          string            `json:"groupKey"`
	Status            string            `json:"status"`
	Receiver          string            `json:"receiver"`
	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`
	ExternalURL       string            `json:"externalURL"`
	Alerts            []*Alert          `json:"alerts"`
}

Message is the JSON message sent by Prometheus Alertmanager, see https://prometheus.io/docs/alerting/configuration/#webhook_config for documentation on fields.

Jump to

Keyboard shortcuts

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