New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert Notification Channels as configuration #10487

Closed
ThomasVdBerge opened this Issue Jan 10, 2018 · 13 comments

Comments

Projects
None yet
10 participants
@ThomasVdBerge
Copy link

ThomasVdBerge commented Jan 10, 2018

Since Grafana v5.0.0-pre1, we are now able to use datasources as configuration. The one thing I am still missing is the set Alert Notification Channels as Configuration.

@wangchaobin

This comment has been minimized.

Copy link

wangchaobin commented Mar 9, 2018

Looking foward to this feature.
For some security reason, channels and rules are very difficlut to migrate. If store them as conf file just like dashboards would be perfect.

@peay

This comment has been minimized.

Copy link

peay commented Apr 20, 2018

Unless someone's already working on this, I'll give it a try.

@bergquist

This comment has been minimized.

Copy link
Contributor

bergquist commented Apr 28, 2018

To make this really good we need to change how alerts refer to alert notifications

The alerting model refers to alert notifiers via the numeric ID. So it's very tricky to provision dashboard with alerts using provisioned alert notifiers since we cannot guarantee the order of who alert notifiers are inserted into the DB. To solve this we should introduce string ID's for alert notifiers, just like dashboards and support numeric and string id's when referring to alert notifiers in the alerting model.

@peay

This comment has been minimized.

Copy link

peay commented May 5, 2018

How about modifying rule.NewRuleFromDBAlert to support reading JSONs of the form

{"notifications": [{"name": "xxx"}, {"id": 1}]}

instead of just ids?

orgId, name is already a unique key for alert notification channels, so names should already be non-ambiguous.

Adding a new field as opposed to switching everything to use names would make this backward compatible. This new name field would only be used when provisioning from a YAML file, though: editing in the UI would still set use numeric IDs, which also makes the change easier.

@bergquist

This comment has been minimized.

Copy link
Contributor

bergquist commented May 7, 2018

The problem with using names is that alert notifiers cannot be renamed without breaking all the alerts using that alert notifiers. We need to support both {"uid": "938459"} and old numeric id to be backward compatible.

When introducing the new uid field we can migrate all current notifiers like we did with dashboards https://github.com/grafana/grafana/blob/master/pkg/services/sqlstore/migrations/dashboard_mig.go#L160

@peay

This comment has been minimized.

Copy link

peay commented May 7, 2018

Names would only be used when you provision from YAML though, everything else would still use numeric IDs. But OK, point taken, let me have a stab at adding uid to alert notification channels. Do you prefer this done in #11747 or in a separate PR?

@bergquist

This comment has been minimized.

Copy link
Contributor

bergquist commented May 7, 2018

I would prefer if all the works was done in #11747 since they would depend a little bit on each other.

@ramato-procon

This comment has been minimized.

Copy link

ramato-procon commented Aug 1, 2018

Can you add this to 5.3 please?

@sirkjohannsen

This comment has been minimized.

Copy link

sirkjohannsen commented Aug 1, 2018

Pretty please ???? 😍

@albestia

This comment has been minimized.

Copy link

albestia commented Aug 31, 2018

Please!!! We are trying to automate deployment process and this is our lasting task.
If I can help in any way...

@machbio

This comment has been minimized.

Copy link

machbio commented Oct 23, 2018

sqlite> .schema alert_notification
CREATE TABLE `alert_notification` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
, `org_id` INTEGER NOT NULL
, `name` TEXT NOT NULL
, `type` TEXT NOT NULL
, `settings` TEXT NOT NULL
, `created` DATETIME NOT NULL
, `updated` DATETIME NOT NULL
, `is_default` INTEGER NOT NULL DEFAULT 0);
CREATE UNIQUE INDEX `UQE_alert_notification_org_id_name` ON `alert_notification` (`org_id`,`name`);

Sort of hack for now -

sqlite> select * from alert_notification;
1|1|cda-alerts|slack|{"autoResolve":true,"httpMethod":"POST","recipient":"#grafana-alerts","token":"xoxb-qweqw","uploadImage":true,"url":"https://hooks.slack.com/services/xxxxxxxx"}|2018-10-19 18:25:58|2018-10-23 16:59:33|1
@Lukkie

This comment has been minimized.

Copy link

Lukkie commented Dec 3, 2018

Any updates on this?

@bergquist

This comment has been minimized.

Copy link
Contributor

bergquist commented Jan 28, 2019

closed by #14229

@bergquist bergquist closed this Jan 28, 2019

@bergquist bergquist added this to the 6.0-beta1 milestone Jan 28, 2019

bergquist added a commit that referenced this issue Jan 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment