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.
Click to show internal directories.
Click to hide internal directories.