Alerting: Rule backtesting with experimental UI (#115525)
* add function to convert StateTransition to LokiEntry * add QueryResultBuilder * update backtesting to produce result similar to historian * make shouldRecord public * filter out noop transitions * add experimental front-end * add new fields * move conversion of api model to AlertRule to validation * add extra labels * calculate tick timestamp using the same logic as in scheduler * implement correct logic of calculating first evaluation timestamp * add uid, group and folder uid they are needed for jitter strategy * add JitterOffsetInDuration and JitterStrategy.String() * add config `backtesting_max_evaluations` to [unified_alerting] (not documented for now) * remove obsolete tests * elevate permisisons for backtesting endpoint * move backtesting to separate dir
This commit is contained in:
@@ -68,7 +68,7 @@ func TestBacktesting(t *testing.T) {
|
||||
require.Truef(t, ok, "The data file does not contain a field `data`")
|
||||
|
||||
status, body := apiCli.SubmitRuleForBacktesting(t, request)
|
||||
require.Equal(t, http.StatusOK, status)
|
||||
require.Equalf(t, http.StatusOK, status, "Response: %s", body)
|
||||
var result data.Frame
|
||||
require.NoErrorf(t, json.Unmarshal([]byte(body), &result), "cannot parse response to data frame")
|
||||
})
|
||||
@@ -107,6 +107,7 @@ func TestBacktesting(t *testing.T) {
|
||||
resourcepermissions.SetResourcePermissionCommand{
|
||||
Actions: []string{
|
||||
accesscontrol.ActionAlertingRuleRead,
|
||||
accesscontrol.ActionAlertingRuleUpdate,
|
||||
},
|
||||
Resource: "folders",
|
||||
ResourceID: "*",
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
},
|
||||
"condition": "A",
|
||||
"no_data_state": "Alerting",
|
||||
"title": "test-rule-backtesting-data",
|
||||
"rule_group": "test-group",
|
||||
"namespace_uid": "test-namespace",
|
||||
"data": [
|
||||
{
|
||||
"refId": "A",
|
||||
@@ -193,6 +196,9 @@
|
||||
},
|
||||
"condition": "C",
|
||||
"no_data_state": "Alerting",
|
||||
"title": "test-rule-backtesting-data",
|
||||
"rule_group": "test-group",
|
||||
"namespace_uid": "test-namespace",
|
||||
"data": [
|
||||
{
|
||||
"refId": "A",
|
||||
|
||||
Reference in New Issue
Block a user