alert

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 30 Imported by: 4

Documentation

Overview

Package alert contains logic to send alert notifications to Alertmanager clusters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRelabelConfigs added in v0.21.0

func LoadRelabelConfigs(confYaml []byte) ([]*relabel.Config, error)

LoadRelabelConfigs loads a list of relabel.Config from YAML data.

Types

type APIVersion added in v0.11.0

type APIVersion string

APIVersion represents the API version of the Alertmanager endpoint.

const (
	APIv1 APIVersion = "v1"
	APIv2 APIVersion = "v2"
)

func (*APIVersion) UnmarshalYAML added in v0.11.0

func (v *APIVersion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type AlertingConfig added in v0.10.0

type AlertingConfig struct {
	Alertmanagers []AlertmanagerConfig `yaml:"alertmanagers"`
}

func LoadAlertingConfig added in v0.10.0

func LoadAlertingConfig(confYaml []byte) (AlertingConfig, error)

LoadAlertingConfig loads a list of AlertmanagerConfig from YAML data.

type Alertmanager added in v0.10.0

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

Alertmanager is an HTTP client that can send alerts to a cluster of Alertmanager endpoints.

func NewAlertmanager added in v0.10.0

func NewAlertmanager(logger log.Logger, dispatcher Dispatcher, timeout time.Duration, version APIVersion) *Alertmanager

NewAlertmanager returns a new Alertmanager client.

type AlertmanagerConfig added in v0.10.0

type AlertmanagerConfig struct {
	HTTPClientConfig clientconfig.HTTPClientConfig    `yaml:"http_config"`
	EndpointsConfig  clientconfig.HTTPEndpointsConfig `yaml:",inline"`
	Timeout          model.Duration                   `yaml:"timeout"`
	APIVersion       APIVersion                       `yaml:"api_version"`
}

AlertmanagerConfig represents a client to a cluster of Alertmanager endpoints.

func BuildAlertmanagerConfig added in v0.10.0

func BuildAlertmanagerConfig(address string, timeout time.Duration) (AlertmanagerConfig, error)

BuildAlertmanagerConfig initializes and returns an Alertmanager client configuration from a static address.

func DefaultAlertmanagerConfig added in v0.10.0

func DefaultAlertmanagerConfig() AlertmanagerConfig

func (*AlertmanagerConfig) UnmarshalYAML added in v0.10.0

func (c *AlertmanagerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Dispatcher added in v0.11.0

type Dispatcher interface {
	// Endpoints returns the list of endpoint URLs the dispatcher knows about.
	Endpoints() []*url.URL
	// Do sends an HTTP request and returns a response.
	Do(*http.Request) (*http.Response, error)
}

type Queue

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

Queue is a queue of alert notifications waiting to be sent. The queue is consumed in batches and entries are dropped at the front if it runs full.

func NewQueue

func NewQueue(logger log.Logger, reg prometheus.Registerer, capacity, maxBatchSize int, externalLset labels.Labels, excludeLabels []string, alertRelabelConfigs []*relabel.Config) *Queue

NewQueue returns a new queue. The given label set is attached to all alerts pushed to the queue. The given exclude label set tells what label names to drop including external labels.

func (*Queue) Cap

func (q *Queue) Cap() int

Cap returns the fixed capacity of the queue.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the current length of the queue.

func (*Queue) Pop

func (q *Queue) Pop(termc <-chan struct{}) []*notifier.Alert

Pop takes a batch of alerts from the front of the queue. The batch size is limited according to the queues maxBatchSize limit. It blocks until elements are available or a termination signal is send on termc.

func (*Queue) Push

func (q *Queue) Push(alerts []*notifier.Alert)

Push adds a list of alerts to the queue.

type Sender

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

Sender sends notifications to a dynamic set of alertmanagers.

func NewSender

func NewSender(
	logger log.Logger,
	reg prometheus.Registerer,
	alertmanagers []*Alertmanager,
) *Sender

NewSender returns a new sender. On each call to Send the entire alert batch is sent to each Alertmanager returned by the getter function.

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, alerts []*notifier.Alert)

Send an alert batch to all given Alertmanager clients. TODO(bwplotka): https://github.com/thanos-io/thanos/issues/660.

Jump to

Keyboard shortcuts

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