Files
grafana/pkg/tests/api/alerting/test-data/hysteresis_rule.json
Yuri Tseretyan f6a46744a6 Alerting: Support hysteresis command expression (#75189)
Backend: 

* Update the Grafana Alerting engine to provide feedback to HysteresisCommand. The feedback information is stored in state.Manager as a fingerprint of each state. The fingerprint is persisted to the database. Only fingerprints that belong to Pending and Alerting states are considered as "loaded" and provided back to the command.
   - add ResultFingerprint to state.State. It's different from other fingerprints we store in the state because it is calculated from the result labels.
  -  add rule_fingerprint column to alert_instance
   - update alerting evaluator to accept AlertingResultsReader via context, and update scheduler to provide it.
   - add AlertingResultsFromRuleState that implements the new interface in eval package
   - update getExprRequest to patch the hysteresis command.

* Only one "Recovery Threshold" query is allowed to be used in the alert rule and it must be the Condition.


Frontend:

* Add hysteresis option to Threshold in UI. It's called "Recovery Threshold"
* Add test for getUnloadEvaluatorTypeFromCondition
* Hide hysteresis in panel expressions

* Refactor isInvalid and add test for it
* Remove unnecesary React.memo
* Add tests for updateEvaluatorConditions

---------

Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2024-01-04 11:47:13 -05:00

71 lines
1.6 KiB
JSON

{
"name": "Default",
"interval": "1s",
"rules": [
{
"grafana_alert": {
"title": "Hysteresis Test",
"condition": "C",
"no_data_state": "NoData",
"exec_err_state": "Error",
"data": [
{
"refId": "A",
"datasourceUid": "REPLACE_ME",
"queryType": "",
"relativeTimeRange": {
"from": 600,
"to": 0
},
"model": {
"refId": "A",
"scenarioId": "predictable_csv_wave",
"csvWave": [
{
"timeStep": 1,
"valuesCSV": "5,3,2,1"
}
],
"seriesCount": 1
}
},
{
"refId": "B",
"datasourceUid": "__expr__",
"model": {
"refId": "B",
"type": "reduce",
"reducer": "last",
"expression": "A"
}
},
{
"refId": "C",
"datasourceUid": "__expr__",
"model": {
"refId": "C",
"type": "threshold",
"conditions": [
{
"evaluator": {
"params": [
4
],
"type": "gt"
},
"unloadEvaluator": {
"params": [
2
],
"type": "lt"
}
}
],
"expression": "B"
}
}
]
}
}
]
}