Documentation ¶
Overview ¶
Package alertmanager implements a Service capable of processing webhooks from prometheus alertmanager.
Index ¶
Constants ¶
const ServiceType = "alertmanager"
ServiceType of the Alertmanager service.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct { types.DefaultService // The URL which should be added to alertmanagers config - Populated by Go-NEB after Service registration. WebhookURL string `json:"webhook_url"` // A map of matrix rooms to templates Rooms map[id.RoomID]struct { TextTemplate string `json:"text_template"` HTMLTemplate string `json:"html_template"` MsgType mevt.MessageType `json:"msg_type"` } `json:"rooms"` // contains filtered or unexported fields }
Service contains the Config fields for the Alertmanager service.
This service will send notifications into a Matrix room when Alertmanager sends webhook events to it. It requires a public domain which Alertmanager can reach. Notices will be sent as the service user ID.
For the template strings, take a look at https://golang.org/pkg/text/template/ and the html variant https://golang.org/pkg/html/template/. The data they get is a webhookNotification
You can set msg_type to either m.text or m.notice
Example JSON request:
{ rooms: { "!ewfug483gsfe:localhost": { "text_template": "your plain text template goes here", "html_template": "your html template goes here", "msg_type": "m.text" }, } }
func (*Service) OnReceiveWebhook ¶
func (s *Service) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli types.MatrixClient)
OnReceiveWebhook receives requests from Alertmanager and sends requests to Matrix as a result.
func (*Service) PostRegister ¶
PostRegister deletes this service if there are no registered repos.
type WebhookNotification ¶
type WebhookNotification struct { Version string `json:"version"` GroupKey string `json:"groupKey"` Status string `json:"status"` Receiver string `json:"receiver"` GroupLabels map[string]string `json:"groupLabels"` CommonLabels map[string]string `json:"commonLabels"` CommonAnnotations map[string]string `json:"commonAnnotations"` ExternalURL string `json:"externalURL"` Alerts []struct { Status string `json:"status"` Labels map[string]string `json:"labels"` Annotations map[string]string `json:"annotations"` StartsAt string `json:"startsAt"` EndsAt string `json:"endsAt"` GeneratorURL string `json:"generatorURL"` SilenceURL string } `json:"alerts"` }
WebhookNotification is the payload from Alertmanager