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{
|
NotifierConfig: NotifierConfig{
|
||||||
VSendResolved: true,
|
VSendResolved: true,
|
||||||
},
|
},
|
||||||
|
Message: `{{ template "opsgenie.default.message" . }}`,
|
||||||
Description: `{{ template "opsgenie.default.description" . }}`,
|
Description: `{{ template "opsgenie.default.description" . }}`,
|
||||||
Source: `{{ template "opsgenie.default.source" . }}`,
|
Source: `{{ template "opsgenie.default.source" . }}`,
|
||||||
// TODO: Add a details field with all the alerts.
|
// TODO: Add a details field with all the alerts.
|
||||||
|
@ -283,11 +284,13 @@ type OpsGenieConfig struct {
|
||||||
|
|
||||||
APIKey Secret `yaml:"api_key"`
|
APIKey Secret `yaml:"api_key"`
|
||||||
APIHost string `yaml:"api_host"`
|
APIHost string `yaml:"api_host"`
|
||||||
|
Message string `yaml:"message"`
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
Source string `yaml:"source"`
|
Source string `yaml:"source"`
|
||||||
Details map[string]string `yaml:"details"`
|
Details map[string]string `yaml:"details"`
|
||||||
Teams string `yaml:"teams"`
|
Teams string `yaml:"teams"`
|
||||||
Tags string `yaml:"tags"`
|
Tags string `yaml:"tags"`
|
||||||
|
Note string `yaml:"note"`
|
||||||
|
|
||||||
// Catches all undefined fields and must be empty after parsing.
|
// Catches all undefined fields and must be empty after parsing.
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
|
|
|
@ -630,11 +630,13 @@ type opsGenieMessage struct {
|
||||||
type opsGenieCreateMessage struct {
|
type opsGenieCreateMessage struct {
|
||||||
*opsGenieMessage `json:",inline"`
|
*opsGenieMessage `json:",inline"`
|
||||||
|
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Details map[string]string `json:"details"`
|
Description string `json:"description,omitempty"`
|
||||||
Source string `json:"source"`
|
Details map[string]string `json:"details"`
|
||||||
Teams string `json:"teams,omitempty"`
|
Source string `json:"source"`
|
||||||
Tags string `json:"tags,omitempty"`
|
Teams string `json:"teams,omitempty"`
|
||||||
|
Tags string `json:"tags,omitempty"`
|
||||||
|
Note string `json:"note,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type opsGenieCloseMessage struct {
|
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"
|
apiURL = n.conf.APIHost + "v1/json/alert"
|
||||||
msg = &opsGenieCreateMessage{
|
msg = &opsGenieCreateMessage{
|
||||||
opsGenieMessage: &apiMsg,
|
opsGenieMessage: &apiMsg,
|
||||||
Message: tmpl(n.conf.Description),
|
Message: tmpl(n.conf.Message),
|
||||||
|
Description: tmpl(n.conf.Description),
|
||||||
Details: details,
|
Details: details,
|
||||||
Source: tmpl(n.conf.Source),
|
Source: tmpl(n.conf.Source),
|
||||||
Teams: tmpl(n.conf.Teams),
|
Teams: tmpl(n.conf.Teams),
|
||||||
Tags: tmpl(n.conf.Tags),
|
Tags: tmpl(n.conf.Tags),
|
||||||
|
Note: tmpl(n.conf.Note),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,7 +31,17 @@
|
||||||
{{ define "pagerduty.default.instances" }}{{ template "__text_alert_list" . }}{{ end }}
|
{{ 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 }}
|
{{ 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