Skip to content

Commit

Permalink
Merge pull request #69 from K-Phoen/notification-channels
Browse files Browse the repository at this point in the history
Allow notification channels to be defined as a list in alerts
  • Loading branch information
K-Phoen authored Jun 16, 2020
2 parents e44987b + 382ea98 commit a7962c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions decoder/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions doc/graph_panels_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7962c0

Please sign in to comment.