Alerting: Set "value" with evalmatches in G Managed (#34075)

When, and currently only when using a classic condition, evaluation information is added (which is like the EvalMatches from dashboard alerting).

This is returned via the API and can be included in notifications by reading the `__value__` label attached `.Alerts` in the template. It is a string.
This commit is contained in:
Kyle Brandt
2021-05-18 09:12:39 -04:00
committed by GitHub
parent 592a3af40e
commit 63b2dd06a5
7 changed files with 129 additions and 7 deletions
+6
View File
@@ -63,6 +63,11 @@ type Result struct {
Error error
EvaluatedAt time.Time
EvaluationDuration time.Duration
// EvaluationSring is a string representation of evaluation data such
// as EvalMatches (from "classic condition"), and in the future from operations
// like SSE "math".
EvaluationString string
}
// State is an enum of the evaluation State for an alert instance.
@@ -265,6 +270,7 @@ func evaluateExecutionResult(execResults ExecutionResults, ts time.Time) Results
Instance: f.Fields[0].Labels,
EvaluatedAt: ts,
EvaluationDuration: time.Since(ts),
EvaluationString: extractEvalString(f),
}
switch {