OpsGenie Notifier, fixes and additions:
- OpsGenie notifier confused the description and message fields - Also added the notes field.
This commit is contained in:
parent
42c193b136
commit
de2252911e
|
@ -87,6 +87,7 @@ var (
|
|||
NotifierConfig: NotifierConfig{
|
||||
VSendResolved: true,
|
||||
},
|
||||
Message: `{{ template "opsgenie.default.message" . }}`,
|
||||
Description: `{{ template "opsgenie.default.description" . }}`,
|
||||
Source: `{{ template "opsgenie.default.source" . }}`,
|
||||
// TODO: Add a details field with all the alerts.
|
||||
|
@ -283,11 +284,13 @@ type OpsGenieConfig struct {
|
|||
|
||||
APIKey Secret `yaml:"api_key"`
|
||||
APIHost string `yaml:"api_host"`
|
||||
Message string `yaml:"message"`
|
||||
Description string `yaml:"description"`
|
||||
Source string `yaml:"source"`
|
||||
Details map[string]string `yaml:"details"`
|
||||
Teams string `yaml:"teams"`
|
||||
Tags string `yaml:"tags"`
|
||||
Note string `yaml:"note"`
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
|
|
@ -630,11 +630,13 @@ type opsGenieMessage struct {
|
|||
type opsGenieCreateMessage struct {
|
||||
*opsGenieMessage `json:",inline"`
|
||||
|
||||
Message string `json:"message"`
|
||||
Details map[string]string `json:"details"`
|
||||
Source string `json:"source"`
|
||||
Teams string `json:"teams,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Details map[string]string `json:"details"`
|
||||
Source string `json:"source"`
|
||||
Teams string `json:"teams,omitempty"`
|
||||
Tags string `json:"tags,omitempty"`
|
||||
Note string `json:"note,omitempty"`
|
||||
}
|
||||
|
||||
type opsGenieCloseMessage struct {
|
||||
|
@ -682,11 +684,13 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) error {
|
|||
apiURL = n.conf.APIHost + "v1/json/alert"
|
||||
msg = &opsGenieCreateMessage{
|
||||
opsGenieMessage: &apiMsg,
|
||||
Message: tmpl(n.conf.Description),
|
||||
Message: tmpl(n.conf.Message),
|
||||
Description: tmpl(n.conf.Description),
|
||||
Details: details,
|
||||
Source: tmpl(n.conf.Source),
|
||||
Teams: tmpl(n.conf.Teams),
|
||||
Tags: tmpl(n.conf.Tags),
|
||||
Note: tmpl(n.conf.Note),
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -31,7 +31,17 @@
|
|||
{{ define "pagerduty.default.instances" }}{{ template "__text_alert_list" . }}{{ end }}
|
||||
|
||||
|
||||
{{ define "opsgenie.default.description" }}{{ template "__subject" . }}{{ end }}
|
||||
{{ define "opsgenie.default.message" }}{{ template "__subject" . }}{{ end }}
|
||||
{{ define "opsgenie.default.description" }}{{ .CommonAnnotations.SortedPairs.Values | join " " }}
|
||||
{{ if gt (len .Alerts.Firing) 0 -}}
|
||||
Alerts Firing:
|
||||
{{ template "__text_alert_list" .Alerts.Firing }}
|
||||
{{- end }}
|
||||
{{ if gt (len .Alerts.Resolved) 0 -}}
|
||||
Alerts Resolved:
|
||||
{{ template "__text_alert_list" .Alerts.Resolved }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ define "opsgenie.default.source" }}{{ template "__alertmanagerURL" . }}{{ end }}
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
120
ui/bindata.go
120
ui/bindata.go
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue