Documentation
¶
Overview ¶
* Code holding/handling the Alertmanager native webhook format
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlertmanagerAlertV4 ¶
type AlertmanagerAlertV4 struct { Status string `yaml:"status"` // enum: resolved, firing Labels map[string]string `yaml:"labels"` // K=V map Annotations map[string]string `yaml:"annotations"` // K=V map StartsAt string `yaml:"startsAt"` EndsAt string `yaml:"endsAt"` GeneratorURL string `yaml:"generatorURL"` OriginalGeneratorURL string // Used by the AlertmanagerWebhookTemplateV4 to capture the non-transmuted prometheus URL Fingerprint string `yaml:"fingerprint"` }
type AlertmanagerWebhookInputV4 ¶
type AlertmanagerWebhookInputV4 struct { Version string `yaml:"version"` GroupKey string `yaml:"groupKey"` TruncatedAlertCount int `yaml:"truncatedAlerts"` Status string `yaml:"status"` // enum: resolved, firing Receiver string `yaml:"receiver"` GroupLabels map[string]string `yaml:"groupLabels"` // K=V map CommonLabels map[string]string `yaml:"commonLabels"` // K=V map CommonAnnotations map[string]string `yaml:"commonAnnotations"` // K=V map ExternalURL string `yaml:"externalURL"` Alerts []*AlertmanagerAlertV4 `yaml:"alerts"` }
{ "version": "4", "groupKey": <string>, // key identifying the group of alerts (e.g. to deduplicate) "truncatedAlerts": <int>, // how many alerts have been truncated due to "max_alerts" "status": "<resolved|firing>", "receiver": <string>, "groupLabels": <object>, "commonLabels": <object>, "commonAnnotations": <object>, "externalURL": <string>, // backlink to the Alertmanager. "alerts": [ { "status": "<resolved|firing>", "labels": <object>, "annotations": <object>, "startsAt": "<rfc3339>", "endsAt": "<rfc3339>", "generatorURL": <string>, // identifies the entity that caused the alert "fingerprint": <string> // fingerprint to identify the alert }, ... ] }
func (*AlertmanagerWebhookInputV4) Prepare ¶
func (a *AlertmanagerWebhookInputV4) Prepare() (*AlertmanagerWebhookTemplateV4, error)
Prepare is the operative function to take an accepted Alertmanager webhook request and "format" it to execute as data to the template function. URLs are transmuted, OS environment is added.
func (*AlertmanagerWebhookInputV4) String ¶
func (a *AlertmanagerWebhookInputV4) String() string
type AlertmanagerWebhookTemplateV4 ¶
type AlertmanagerWebhookTemplateV4 struct { Version string `yaml:"version"` GroupKey string `yaml:"groupKey"` TruncatedAlertCount int `yaml:"truncatedAlerts"` Status string `yaml:"status"` // enum: resolved, firing Receiver string `yaml:"receiver"` GroupLabels map[string]string `yaml:"groupLabels"` // K=V map CommonLabels map[string]string `yaml:"commonLabels"` // K=V map CommonAnnotations map[string]string `yaml:"commonAnnotations"` // K=V map ExternalURL string `yaml:"externalURL"` OriginalExternalURL string Alerts []*AlertmanagerAlertV4 `yaml:"alerts"` Env map[string]string }
func (*AlertmanagerWebhookTemplateV4) String ¶
func (a *AlertmanagerWebhookTemplateV4) String() string
type AlertmanagerWebhookVersionInvalid ¶
type AlertmanagerWebhookVersionInvalid string
func (AlertmanagerWebhookVersionInvalid) Error ¶
func (a AlertmanagerWebhookVersionInvalid) Error() string
type RoutingConfig ¶
type RoutingConfig struct { AlertmanagerBaseURL string PrometheusBaseURL string ApplicationName string // used for naming prometheus metrics - if blank, metrics will not be added // contains filtered or unexported fields }
* RoutingConfig is a central feature for this software; Alertmanager alerts often have a pre-canned URL scheme that references the internal k8s hostname and namespace, * but these are not accessible outside the cluster. By using a URL transmutation scheme, we can adapt all alert-specific URLs to use a different URL scheme, perhaps * involving an external load balancer for the Alertmanager & Prometheus instances or perhaps utilizing the Kubernetes API Service proxy, possibly with a higher-level * cluster proxy such as Rancher on top of it. This allows users to click links in alerts and have them route to a workable URL, without requiring reconfiguration of * the Alertmanager software.
var GlobalRoutingConfig *RoutingConfig
Global set of alertmanager & prometheus URL transmute objects; configured on software startup
func (*RoutingConfig) IsInitialized ¶
func (r *RoutingConfig) IsInitialized() bool
type URLReplacements ¶
type URLReplacements struct { NewURLPrefix string `yaml:"prefix"` // contains filtered or unexported fields }
func (*URLReplacements) Parse ¶
func (u *URLReplacements) Parse() error
func (*URLReplacements) Transmute ¶
func (u *URLReplacements) Transmute(in string) string
Main function for URLReplacements is to transmute a URL into the intended usable form.