feat(alerting): show alertin state in panel header, closes #6136

This commit is contained in:
Torkel Ödegaard
2016-09-30 17:37:47 +02:00
parent 2c4524bbfd
commit 7c339f0794
19 changed files with 194 additions and 53 deletions
+2 -2
View File
@@ -74,9 +74,9 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
continue
}
// backward compatability check, can be removed later
enabled, hasEnabled := jsonAlert.CheckGet("enabled")
if !hasEnabled || !enabled.MustBool() {
if hasEnabled && enabled.MustBool() == false {
continue
}
-2
View File
@@ -42,7 +42,6 @@ func TestAlertRuleExtraction(t *testing.T) {
"name": "name1",
"message": "desc1",
"handler": 1,
"enabled": true,
"frequency": "60s",
"conditions": [
{
@@ -66,7 +65,6 @@ func TestAlertRuleExtraction(t *testing.T) {
"name": "name2",
"message": "desc2",
"handler": 0,
"enabled": true,
"frequency": "60s",
"severity": "warning",
"conditions": [
+17
View File
@@ -17,6 +17,7 @@ func init() {
bus.AddHandler("sql", DeleteAlertById)
bus.AddHandler("sql", GetAllAlertQueryHandler)
bus.AddHandler("sql", SetAlertState)
bus.AddHandler("sql", GetAlertStatesForDashboard)
}
func GetAlertById(query *m.GetAlertByIdQuery) error {
@@ -241,3 +242,19 @@ func SetAlertState(cmd *m.SetAlertStateCommand) error {
return nil
})
}
func GetAlertStatesForDashboard(query *m.GetAlertStatesForDashboardQuery) error {
var rawSql = `SELECT
id,
dashboard_id,
panel_id,
state,
new_state_date
FROM alert
WHERE org_id = ? AND dashboard_id = ?`
query.Result = make([]*m.AlertStateInfoDTO, 0)
err := x.Sql(rawSql, query.OrgId, query.DashboardId).Find(&query.Result)
return err
}