Alerting: Add a "Reason" to Alert Instances to show underlying cause of state. (#49259)

This change adds a field to state.State and models.AlertInstance
that indicate the "Reason" that an instance has its current state. This
helps us account for cases where the state is "Normal" but the
underlying evaluation returned "NoData" or "Error", for example.

Fixes #42606

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
Joe Blubaugh
2022-05-23 16:49:49 +08:00
committed by GitHub
parent 26a206cce2
commit 1cc034d960
21 changed files with 253 additions and 96 deletions
@@ -155,6 +155,11 @@ func AlertInstanceMigration(mg *migrator.Migrator) {
mg.AddMigration("add index rule_org_id, current_state on alert_instance", migrator.NewAddIndexMigration(alertInstance, &migrator.Index{
Cols: []string{"rule_org_id", "current_state"}, Type: migrator.IndexType,
}))
mg.AddMigration("add current_reason column related to current_state",
migrator.NewAddColumnMigration(alertInstance, &migrator.Column{
Name: "current_reason", Type: migrator.DB_NVarchar, Length: 190, Nullable: true,
}))
}
func AddAlertRuleMigrations(mg *migrator.Migrator, defaultIntervalSeconds int64) {