Commit 5cf97118 by Torkel Ödegaard

feat(alerting): added eval match to test results

parent 2f953d75
......@@ -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())
......
......@@ -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"`
}
......@@ -53,8 +53,9 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
Metric: series.Name,
Value: reducedValue,
})
context.Firing = true
}
context.Firing = evalMatch
}
}
......
///<reference path="../../headers/common.d.ts" />
import _ from 'lodash';
import {QueryPart} from 'app/core/components/query_part/query_part';
import alertDef from './alert_def';
export class AlertModel {
constructor() {
}
}
......@@ -67,6 +67,13 @@
<label class="gf-form-label query-keyword" ng-show="conditionModel.evaluator.params.length === 2">TO</label>
<input class="gf-form-input max-width-7" type="number" ng-if="conditionModel.evaluator.params.length === 2" ng-model="conditionModel.evaluator.params[1]" ng-change="ctrl.evaluatorParamsChanged()"></input>
</div>
<gf-form-switch class="gf-form"
label="OR NO VALUE"
label-class="query-keyword"
checked="dashboard.editable"
>
</gf-form-switch>
<div class="gf-form">
<label class="gf-form-label">
<a class="pointer" tabindex="1" ng-click="ctrl.removeCondition($index)">
......
......@@ -53,10 +53,10 @@ export class ThresholdMapper {
thresholds.push({value: value1, op: 'gt'});
thresholds.push({value: value2, op: 'lt'});
}
break;
}
}
break;
}
for (var t of panel.thresholds) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment