alerts

package
v0.0.0-...-3f7b053 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultAlertTmpl reports all alert labels and annotations in a markdown format
	// that renders correctly in github issues.
	//
	// Example:
	//
	// Alertmanager URL: http://localhost:9093
	//
	//  * firing
	//
	//	Labels:
	//
	//	 - alertname = DiskRunningFull
	//	 - dev = sda1
	//	 - instance = example1
	//
	//	Annotations:
	//
	//	 - test = value
	//
	//  * firing
	//
	//	Labels:
	//
	//	 - alertname = DiskRunningFull
	//	 - dev = sda2
	//   - instance = example2
	DefaultAlertTmpl = `` /* 394-byte string literal not displayed */

	// DefaultTitleTmpl will be used to format the title string if it's not
	// overridden.
	DefaultTitleTmpl = `{{ .Data.GroupLabels.alertname }}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ReceiverClient

type ReceiverClient interface {
	CloseIssue(issue *github.Issue) (*github.Issue, error)
	CreateIssue(repo, title, body string, extra []string) (*github.Issue, error)
	LabelIssue(issue *github.Issue, label string, add bool) error
	ListOpenIssues() ([]*github.Issue, error)
}

ReceiverClient defines all issue operations needed by the ReceiverHandler.

type ReceiverHandler

type ReceiverHandler struct {
	// Client is an implementation of the ReceiverClient interface. Client is used
	// to handle requests.
	Client ReceiverClient

	// AutoClose indicates whether resolved issues that are still open should be
	// closed automatically.
	AutoClose bool

	// ResolvedLabel is applied to issues when their corresponding alerts are
	// resolved.
	ResolvedLabel string

	// DefaultRepo is the repository where all alerts without a "repo" label will
	// be created. Repo must exist.
	DefaultRepo string

	// ExtraLabels values will be added to new issues as additional labels.
	ExtraLabels []string
	// contains filtered or unexported fields
}

ReceiverHandler contains data needed for HTTP handlers.

func NewReceiver

func NewReceiver(client ReceiverClient, githubRepo string, autoClose bool, resolvedLabel string, extraLabels []string, titleTmplStr string, alertTmplStr string) (*ReceiverHandler, error)

NewReceiver creates a new ReceiverHandler.

func (*ReceiverHandler) ServeHTTP

func (rh *ReceiverHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP receives and processes alertmanager notifications. If the alert is firing and a github issue does not yet exist, one is created. If the alert is resolved and a github issue exists, then it is closed.

Jump to

Keyboard shortcuts

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