feat(alerting): serialize whole target obj from dashboard

This commit is contained in:
bergquist 2016-04-25 16:38:27 +02:00
parent 25f6ec8b53
commit ddd826616b
2 changed files with 5 additions and 2 deletions

View File

@ -57,7 +57,10 @@ func (cmd *SaveDashboardCommand) GetAlertModels() *[]AlertRule {
target := simplejson.NewFromAny(targetsObj)
if target.Get("refId").MustString() == alert.QueryRefId {
alert.Query = target.Get("target").MustString()
targetJson, err := target.MarshalJSON()
if err == nil {
alert.Query = string(targetJson)
}
continue
}
}

View File

@ -287,7 +287,7 @@ func TestAlertModel(t *testing.T) {
fmt.Println(v.Query)
}
So(alerts[0].Query, ShouldEqual, "statsd.fakesite.counters.session_start.desktop.count")
So(alerts[0].Query, ShouldEqual, "{\"hide\":false,\"refId\":\"A\",\"target\":\"statsd.fakesite.counters.session_start.desktop.count\"}")
})
})
}