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

View File

@@ -74,8 +74,9 @@ func (st *Manager) setNextState(alertRule *ngModels.AlertRule, result eval.Resul
currentState.LastEvaluationTime = result.EvaluatedAt
currentState.EvaluationDuration = result.EvaluationDuration
currentState.Results = append(currentState.Results, Evaluation{
EvaluationTime: result.EvaluatedAt,
EvaluationState: result.State,
EvaluationTime: result.EvaluatedAt,
EvaluationState: result.State,
EvaluationString: result.EvaluationString,
})
st.Log.Debug("setting alert state", "uid", alertRule.UID)

View File

@@ -24,8 +24,9 @@ type State struct {
}
type Evaluation struct {
EvaluationTime time.Time
EvaluationState eval.State
EvaluationTime time.Time
EvaluationState eval.State
EvaluationString string
}
func resultNormal(alertState *State, result eval.Result) *State {