alerting: set model refID if missing/mismatch (#114441)
This commit is contained in:
@@ -252,7 +252,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"folderUid": "default",
|
||||
"uid": "%s",
|
||||
@@ -270,7 +270,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
}, {
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"folderUid": "default",
|
||||
"uid": "%s",
|
||||
"health": "ok",
|
||||
@@ -317,7 +317,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
"rules": [{
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiring",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"folderUid": "default",
|
||||
"uid": "%s",
|
||||
@@ -335,7 +335,7 @@ func TestIntegrationPrometheusRules(t *testing.T) {
|
||||
}, {
|
||||
"state": "inactive",
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"folderUid": "default",
|
||||
"uid": "%s",
|
||||
"health": "ok",
|
||||
@@ -639,7 +639,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"name": "AlwaysFiring",
|
||||
"uid": "%s",
|
||||
"folderUid": "default",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"keepFiringFor": 15,
|
||||
"annotations": {
|
||||
@@ -656,7 +656,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"name": "AlwaysFiringButSilenced",
|
||||
"uid": "%s",
|
||||
"folderUid": "default",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"health": "ok",
|
||||
"isPaused": false,
|
||||
"type": "alerting",
|
||||
@@ -688,7 +688,7 @@ func TestIntegrationPrometheusRulesFilterByDashboard(t *testing.T) {
|
||||
"name": "AlwaysFiring",
|
||||
"uid": "%s",
|
||||
"folderUid": "default",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"type\":\"math\"}}]",
|
||||
"query": "[{\"refId\":\"A\",\"queryType\":\"\",\"relativeTimeRange\":{\"from\":18000,\"to\":10800},\"datasourceUid\":\"__expr__\",\"model\":{\"expression\":\"2 + 3 \\u003e 1\",\"intervalMs\":1000,\"maxDataPoints\":43200,\"refId\":\"A\",\"type\":\"math\"}}]",
|
||||
"duration": 10,
|
||||
"keepFiringFor": 15,
|
||||
"annotations": {
|
||||
|
||||
@@ -1166,6 +1166,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}],
|
||||
@@ -1209,6 +1210,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}],
|
||||
@@ -1264,6 +1266,7 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"expression": "2 + 3 \u003e 1",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}],
|
||||
@@ -1610,7 +1613,7 @@ func TestIntegrationRuleCreate(t *testing.T) {
|
||||
To: apimodels.Duration(15 * time.Minute),
|
||||
},
|
||||
DatasourceUID: expr.DatasourceUID,
|
||||
Model: json.RawMessage(`{"expression":"1","intervalMs":1000,"maxDataPoints":43200,"type":"math"}`),
|
||||
Model: json.RawMessage(`{"expression":"1","intervalMs":1000,"maxDataPoints":43200,"refId":"A","type":"math"}`),
|
||||
},
|
||||
},
|
||||
UpdatedBy: &apimodels.UserInfo{
|
||||
@@ -2681,6 +2684,7 @@ func TestIntegrationQuota(t *testing.T) {
|
||||
"expression":"2 + 4 \u003E 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -2798,6 +2802,7 @@ func TestIntegrationDeleteFolderWithRules(t *testing.T) {
|
||||
"expression": "2 + 3 > 1",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
@@ -3285,6 +3290,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -3331,6 +3337,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -3683,6 +3690,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -3729,6 +3737,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003e 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -3872,6 +3881,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -3995,6 +4005,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
@@ -4093,6 +4104,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"expression":"2 + 3 \u003C 1",
|
||||
"intervalMs":1000,
|
||||
"maxDataPoints":43200,
|
||||
"refId":"A",
|
||||
"type":"math"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"expression": "0 \u003e 0",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
@@ -55,6 +56,7 @@
|
||||
"expression": "0 == 0",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"expression": "0/0",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"expression": "0 \u003e 0",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
@@ -54,6 +55,7 @@
|
||||
"expression": "0 == 0",
|
||||
"intervalMs": 1000,
|
||||
"maxDataPoints": 43200,
|
||||
"refId": "A",
|
||||
"type": "math"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user