Alerting: rule backtesting API (#57318)

* Implement backtesting engine that can process regular rule specification (with queries to datasource) as well as special kind of rules that have data frame instead of query.
* declare a new API endpoint and model
* add feature toggle `alertingBacktesting`
This commit is contained in:
Yuri Tseretyan
2022-12-14 09:44:14 -05:00
committed by GitHub
parent 258696409d
commit ad09feed83
24 changed files with 1871 additions and 1 deletions
@@ -2384,6 +2384,29 @@
}
}
},
"/api/v1/rule/backtest": {
"post": {
"description": "Test rule",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"testing"
],
"operationId": "BacktestConfig",
"responses": {
"200": {
"description": "BacktestResult",
"schema": {
"$ref": "#/definitions/BacktestResult"
}
}
}
}
},
"/api/v1/rule/test/grafana": {
"post": {
"description": "Test a rule against Grafana ruler",
@@ -2748,6 +2771,60 @@
}
}
},
"BacktestConfig": {
"type": "object",
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"condition": {
"type": "string"
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/AlertQuery"
}
},
"for": {
"$ref": "#/definitions/Duration"
},
"from": {
"type": "string",
"format": "date-time"
},
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"no_data_state": {
"type": "string",
"enum": [
"Alerting",
"NoData",
"OK"
]
},
"title": {
"type": "string"
},
"to": {
"type": "string",
"format": "date-time"
}
}
},
"BacktestResult": {
"$ref": "#/definitions/Frame"
},
"BasicAuth": {
"type": "object",
"title": "BasicAuth contains basic HTTP authentication credentials.",