alertmanager

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: EUPL-1.2 Imports: 14 Imported by: 0

Documentation

Overview

Package alertmanager contains a simple Prometheus Alertmanager client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	*template.Alert
}

Alert represents an Alert received from Alertmanager via webhook. It is extended with the `status` attribute, and various convenient functions for formatting.

func (*Alert) AlertName

func (a *Alert) AlertName() string

AlertName returns the value of the `alertname` label.

func (*Alert) LabelString

func (a *Alert) LabelString() string

LabelString returns a formatted list of message labels in the form {key="value"}.

func (*Alert) StatusString

func (a *Alert) StatusString() string

StatusString returns a string representing the status. This is either `resolved`, `silenced`, the value of the `severity` label, or `alert`.

func (*Alert) Summary

func (a *Alert) Summary() string

Summary returns the `summary` annotation when set, the `resolved` annotation for `resolved` messages, or an empty string if neither annotation is present.

type Client

type Client struct {
	API *alertmanager.AlertmanagerAPI
}

Client represents a multi-functional Alertmanager API client.

func NewClient

func NewClient(baseURL string) (*Client, error)

NewClient creates an Alertmanager API client.

func (*Client) CreateSilence added in v0.4.0

func (am *Client) CreateSilence(ctx context.Context, s Silence) (string, error)

CreateSilence creates the given silence.

func (*Client) DeleteSilence added in v0.4.0

func (am *Client) DeleteSilence(ctx context.Context, id string) error

DeleteSilence deletes the silence with the given ID.

func (*Client) GetAlert

func (am *Client) GetAlert(ctx context.Context, id string) (alert *Alert, err error)

GetAlert retrieves an alert with a given ID.

func (*Client) GetAlerts

func (am *Client) GetAlerts(ctx context.Context, silenced bool) ([]*Alert, error)

GetAlerts retrieves all silenced or non-silenced alerts.

func (*Client) GetSilences added in v0.4.0

func (am *Client) GetSilences(ctx context.Context) ([]Silence, error)

GetSilences returns a list of silences from Alertmanager.

type Message

type Message struct {
	*webhook.Message
	Alerts []*Alert `json:"alerts"`
}

Message represents a message received from Alertmanager via webhook.

type Silence added in v0.4.0

type Silence struct {
	*models.GettableSilence
}

Silence represents a silence configured in Alertmanager.

func (*Silence) Comment added in v0.4.0

func (s *Silence) Comment() string

Comment returns the comment associated with the Silence.

func (*Silence) CreatedBy added in v0.4.0

func (s *Silence) CreatedBy() string

CreatedBy returns the creator of the Silence.

func (*Silence) EndsAt added in v0.4.0

func (s *Silence) EndsAt() time.Time

EndsAt returns the time that the Silence ends at.

func (*Silence) ID added in v0.4.0

func (s *Silence) ID() string

ID returns the ID of the Silence.

func (*Silence) Matchers added in v0.4.0

func (s *Silence) Matchers() labels.Matchers

Matchers returns the [label.Matchers] for the Silence.

func (*Silence) SetMatchers added in v0.4.0

func (s *Silence) SetMatchers(matchers labels.Matchers)

SetMatchers sets the Matchers based on the given [label.Matchers].

func (*Silence) StartsAt added in v0.4.0

func (s *Silence) StartsAt() time.Time

StartsAt returns the time that the Silence starts at.

func (*Silence) Status added in v0.4.0

func (s *Silence) Status() string

Status returns the status state string of the Silence.

func (*Silence) UpdatedAt added in v0.4.0

func (s *Silence) UpdatedAt() time.Time

UpdatedAt returns the time when the Silence was last updated.

Jump to

Keyboard shortcuts

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