alerts

package
v0.0.0-...-5220feb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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