alertmanager

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package alertmanager provides types for working with alert manager webhooks.

Index

Constants

View Source
const (
	StatusFiring   = "firing"
	StatusResolved = "resolved"
)

Constants for alert statuses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

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

The Alert type represents a single alert within a webhook payload.

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, webhook Webhook) error
}

The Dispatcher interface describes types that can handle alert manager webhooks and forward them somewhere.

type Webhook

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

The Webhook type represents the structure of an alert manager webhook.

type WebhookHandler

type WebhookHandler struct {
	transport.HTTP
	// contains filtered or unexported fields
}

The WebhookHandler type is used to handle inbound alert manager webhooks via HTTP.

func NewWebhookHandler

func NewWebhookHandler(dispatcher Dispatcher) *WebhookHandler

NewWebhookHandler returns a new WebhookHandler instance that will forward webhooks to the given Dispatcher implementation.

func (*WebhookHandler) Handle

func (wh *WebhookHandler) Handle(w http.ResponseWriter, r *http.Request)

Handle an inbound HTTP request.

func (*WebhookHandler) Register

func (wh *WebhookHandler) Register(r *mux.Router)

Register endpoints on the provided router.

Jump to

Keyboard shortcuts

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