From 382ea98e92a33a993c011d6bdefbb123611cd9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Tue, 16 Jun 2020 18:10:12 +0200 Subject: [PATCH] Allow notification channels to be defined as a list in alerts --- decoder/graph.go | 5 +++++ doc/graph_panels_yaml.md | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/decoder/graph.go b/decoder/graph.go index 899306cc..26e5894b 100644 --- a/decoder/graph.go +++ b/decoder/graph.go @@ -173,6 +173,7 @@ type GraphAlert struct { For string If []AlertCondition Notify string + Notifications []string Message string OnNoData string `yaml:"on_no_data"` OnExecutionError string `yaml:"on_execution_error"` @@ -223,6 +224,10 @@ func (a GraphAlert) toOptions() ([]alert.Option, error) { opts = append(opts, alert.Message(a.Message)) } + for _, channel := range a.Notifications { + opts = append(opts, alert.NotifyChannel(channel)) + } + for _, condition := range a.If { conditionOpt, err := condition.toOption() if err != nil { diff --git a/doc/graph_panels_yaml.md b/doc/graph_panels_yaml.md index fb56920e..db68796b 100644 --- a/doc/graph_panels_yaml.md +++ b/doc/graph_panels_yaml.md @@ -39,8 +39,10 @@ rows: title: Too many heap allocations evaluate_every: 1m for: 1m - # ID of the notification channel - notify: 1 + # UID of the notification channel + notify: "P-N3fxuZz" + # UIDs of the notification channels + #notifications: ["P-N3fxuZz"] message: "Wow, a we're allocating a lot." # Valid values are: no_data, alerting, keep_state, ok on_no_data: alerting