silence: Add to multi alert-mode as well
This commit is contained in:
parent
1e44ba5694
commit
0a3ead8b6e
2 changed files with 18 additions and 0 deletions
|
@ -69,6 +69,10 @@ alertmanager {
|
||||||
# to create a silence via the Alertmanager API. Because of limitations in ntfy,
|
# to create a silence via the Alertmanager API. Because of limitations in ntfy,
|
||||||
# the request will be proxied through ntfy-alertmanager. Therefore ntfy-alertmanager
|
# the request will be proxied through ntfy-alertmanager. Therefore ntfy-alertmanager
|
||||||
# needs to be exposed to external network requests and base-url has to be set.
|
# needs to be exposed to external network requests and base-url has to be set.
|
||||||
|
#
|
||||||
|
# When alert-mode is set to "single" all alert labels will be used to create the silence.
|
||||||
|
# When it is "multi" common labels between all the alerts will be used. WARNING: This
|
||||||
|
# could silence unwanted alerts.
|
||||||
silence-duration 24h
|
silence-duration 24h
|
||||||
# Basic authentication (https://prometheus.io/docs/alerting/latest/https/)
|
# Basic authentication (https://prometheus.io/docs/alerting/latest/https/)
|
||||||
user user
|
user user
|
||||||
|
|
14
main.go
14
main.go
|
@ -199,6 +199,20 @@ func (rcv *receiver) multiAlertNotification(p *payload) *notification {
|
||||||
n.priority = priority
|
n.priority = priority
|
||||||
n.tags = tagString
|
n.tags = tagString
|
||||||
|
|
||||||
|
if rcv.cfg.am.SilenceDuration != 0 {
|
||||||
|
if rcv.cfg.BaseURL == "" {
|
||||||
|
rcv.logger.Error("Failed to create silence action: No base-url set")
|
||||||
|
}
|
||||||
|
|
||||||
|
s := &silenceBody{AlertManagerURL: p.ExternalURL, Labels: p.CommonLabels}
|
||||||
|
b, err := json.Marshal(s)
|
||||||
|
if err != nil {
|
||||||
|
rcv.logger.Errorf("Failed to create silence action: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
n.silenceBody = base64.StdEncoding.EncodeToString(b)
|
||||||
|
}
|
||||||
|
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue