NGAlert: Migrate old notification channel config (#33846)

* NGAlert: Migrate old notification channel config

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Copy the required structs and functions

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix lint

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix review comments and error on discontinued channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Use both ID and UID to map channels, attach UID to channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix lint

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Bug fixes

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Use alert table instead of dashboard for channel IDs

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Fix offline reviews: don't add empty receivers and routes, add receiver for unmigrated channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Handle multiple default channels, pick default from used channels

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>

* Include default channels in all receivers

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
Ganesh Vernekar
2021-05-19 21:10:12 +02:00
committed by GitHub
parent 533be16787
commit e52f718a87
3 changed files with 442 additions and 6 deletions
@@ -21,8 +21,8 @@ type dashAlert struct {
}
var slurpDashSQL = `
SELECT id,
org_id,
SELECT id,
org_id,
dashboard_id,
panel_id,
org_id,
@@ -70,7 +70,8 @@ type dashAlertSettings struct {
// dashAlertNot is the object that represents the Notifications array in
// dashAlertSettings
type dashAlertNot struct {
UID string `json:"uid"`
UID string `json:"uid,omitempty"`
ID int64 `json:"id,omitempty"`
}
// dashAlertingConditionJSON is like classic.ClassicConditionJSON except that it