mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
feat(alerting): added eval match to test results
This commit is contained in:
parent
2f953d75a6
commit
5cf9711862
@ -106,6 +106,9 @@ func AlertTest(c *middleware.Context, dto dtos.AlertTestCommand) Response {
|
|||||||
for _, log := range res.Logs {
|
for _, log := range res.Logs {
|
||||||
dtoRes.Logs = append(dtoRes.Logs, &dtos.AlertTestResultLog{Message: log.Message, Data: log.Data})
|
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())
|
dtoRes.TimeMs = fmt.Sprintf("%1.3fms", res.GetDurationMs())
|
||||||
|
|
||||||
|
@ -35,10 +35,11 @@ type AlertTestCommand struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AlertTestResult struct {
|
type AlertTestResult struct {
|
||||||
Firing bool `json:"firing"`
|
Firing bool `json:"firing"`
|
||||||
TimeMs string `json:"timeMs"`
|
TimeMs string `json:"timeMs"`
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
Logs []*AlertTestResultLog `json:"logs,omitempty"`
|
EvalMatches []*EvalMatch `json:"matches,omitempty"`
|
||||||
|
Logs []*AlertTestResultLog `json:"logs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlertTestResultLog struct {
|
type AlertTestResultLog struct {
|
||||||
@ -46,7 +47,8 @@ type AlertTestResultLog struct {
|
|||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlertEvent struct {
|
type EvalMatch struct {
|
||||||
Metric string `json:"metric"`
|
Tags map[string]string `json:"tags,omitempty"`
|
||||||
Value float64 `json:"value"`
|
Metric string `json:"metric"`
|
||||||
|
Value float64 `json:"value"`
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,9 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
|||||||
Metric: series.Name,
|
Metric: series.Name,
|
||||||
Value: reducedValue,
|
Value: reducedValue,
|
||||||
})
|
})
|
||||||
context.Firing = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Firing = evalMatch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
public/app/features/alerting/alert_model.ts
Normal file
11
public/app/features/alerting/alert_model.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
///<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>
|
<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>
|
<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>
|
</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">
|
<div class="gf-form">
|
||||||
<label class="gf-form-label">
|
<label class="gf-form-label">
|
||||||
<a class="pointer" tabindex="1" ng-click="ctrl.removeCondition($index)">
|
<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: value1, op: 'gt'});
|
||||||
thresholds.push({value: value2, op: 'lt'});
|
thresholds.push({value: value2, op: 'lt'});
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var t of panel.thresholds) {
|
for (var t of panel.thresholds) {
|
||||||
|
Loading…
Reference in New Issue
Block a user