diff --git a/pkg/api/alerting.go b/pkg/api/alerting.go
index c829c1ff71c..f20e08a5cad 100644
--- a/pkg/api/alerting.go
+++ b/pkg/api/alerting.go
@@ -106,6 +106,9 @@ func AlertTest(c *middleware.Context, dto dtos.AlertTestCommand) Response {
for _, log := range res.Logs {
dtoRes.Logs = append(dtoRes.Logs, &dtos.AlertTestResultLog{Message: log.Message, Data: log.Data})
}
+ for _, match := range res.EvalMatches {
+ dtoRes.EvalMatches = append(dtoRes.EvalMatches, &dtos.EvalMatch{Metric: match.Metric, Value: match.Value})
+ }
dtoRes.TimeMs = fmt.Sprintf("%1.3fms", res.GetDurationMs())
diff --git a/pkg/api/dtos/alerting.go b/pkg/api/dtos/alerting.go
index bab4eb196ba..0ec0174a949 100644
--- a/pkg/api/dtos/alerting.go
+++ b/pkg/api/dtos/alerting.go
@@ -35,10 +35,11 @@ type AlertTestCommand struct {
}
type AlertTestResult struct {
- Firing bool `json:"firing"`
- TimeMs string `json:"timeMs"`
- Error string `json:"error,omitempty"`
- Logs []*AlertTestResultLog `json:"logs,omitempty"`
+ Firing bool `json:"firing"`
+ TimeMs string `json:"timeMs"`
+ Error string `json:"error,omitempty"`
+ EvalMatches []*EvalMatch `json:"matches,omitempty"`
+ Logs []*AlertTestResultLog `json:"logs,omitempty"`
}
type AlertTestResultLog struct {
@@ -46,7 +47,8 @@ type AlertTestResultLog struct {
Data interface{} `json:"data"`
}
-type AlertEvent struct {
- Metric string `json:"metric"`
- Value float64 `json:"value"`
+type EvalMatch struct {
+ Tags map[string]string `json:"tags,omitempty"`
+ Metric string `json:"metric"`
+ Value float64 `json:"value"`
}
diff --git a/pkg/services/alerting/conditions/query.go b/pkg/services/alerting/conditions/query.go
index e220f42d67d..d94c2d468f2 100644
--- a/pkg/services/alerting/conditions/query.go
+++ b/pkg/services/alerting/conditions/query.go
@@ -53,8 +53,9 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
Metric: series.Name,
Value: reducedValue,
})
- context.Firing = true
}
+
+ context.Firing = evalMatch
}
}
diff --git a/public/app/features/alerting/alert_model.ts b/public/app/features/alerting/alert_model.ts
new file mode 100644
index 00000000000..b7091a3f066
--- /dev/null
+++ b/public/app/features/alerting/alert_model.ts
@@ -0,0 +1,11 @@
+ ///