Alerting: Add integration tests for Rule Export API (#75896)

This commit is contained in:
Yuri Tseretyan
2023-10-05 15:47:49 -04:00
committed by GitHub
parent 51499d7763
commit a66760f9f2
8 changed files with 788 additions and 215 deletions
@@ -0,0 +1,75 @@
{
"apiVersion": 1,
"groups": [
{
"orgId": 1,
"name": "Group1",
"folder": "<dynamic>",
"interval": "1m",
"rules": [
{
"uid": "<dynamic>",
"title": "Rule1",
"condition": "A",
"data": [
{
"refId": "A",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0 \u003e 0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"noDataState": "NoData",
"execErrState": "Alerting",
"for": "5m",
"annotations": {
"annotation": "test-annotation"
},
"labels": {
"label1": "test-label"
},
"isPaused": false
},
{
"uid": "<dynamic>",
"title": "Rule2",
"condition": "A",
"data": [
{
"refId": "A",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0 == 0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"noDataState": "NoData",
"execErrState": "Alerting",
"for": "5m",
"annotations": {
"annotation": "test-annotation"
},
"labels": {
"label1": "test-label"
},
"isPaused": false
}
]
}
]
}
@@ -0,0 +1,92 @@
{
"name": "Group1",
"interval": "1m",
"rules": [
{
"expr": "",
"for": "5m",
"labels": {
"label1": "test-label"
},
"annotations": {
"annotation": "test-annotation"
},
"grafana_alert": {
"id": 1,
"orgId": 1,
"title": "Rule1",
"condition": "A",
"data": [
{
"refId": "A",
"queryType": "",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0 > 0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"updated": "2023-09-29T17:37:19Z",
"intervalSeconds": 60,
"version": 1,
"uid": "<dynamic>",
"namespace_uid": "<dynamic>",
"namespace_id": 0,
"rule_group": "Group1",
"no_data_state": "NoData",
"exec_err_state": "Alerting",
"is_paused": false
}
},
{
"expr": "",
"for": "5m",
"labels": {
"label1": "test-label"
},
"annotations": {
"annotation": "test-annotation"
},
"grafana_alert": {
"id": 2,
"orgId": 1,
"title": "Rule2",
"condition": "A",
"data": [
{
"refId": "A",
"queryType": "",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0 == 0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"updated": "2023-09-29T17:37:19Z",
"intervalSeconds": 60,
"version": 1,
"uid": "<dynamic>",
"namespace_uid": "<dynamic>",
"namespace_id": 0,
"rule_group": "Group1",
"no_data_state": "NoData",
"exec_err_state": "Alerting",
"is_paused": false
}
}
]
}
@@ -0,0 +1,56 @@
{
"name": "Group1",
"interval": "1m",
"rules": [
{
"for" : "5m",
"labels" : {
"label1" : "test-label"
},
"annotations" : {
"annotation" : "test-annotation"
},
"grafana_alert": {
"title": "Rule1",
"condition": "A",
"data": [
{
"refId": "A",
"datasourceUid": "__expr__",
"model": {
"expression": "0 > 0",
"type": "math"
}
}
],
"no_data_state": "NoData",
"exec_err_state": "Alerting"
}
},
{
"for" : "5m",
"labels" : {
"label1" : "test-label"
},
"annotations" : {
"annotation" : "test-annotation"
},
"grafana_alert": {
"title": "Rule2",
"condition": "A",
"data": [
{
"refId": "A",
"datasourceUid": "__expr__",
"model": {
"expression": "0 == 0",
"type": "math"
}
}
],
"no_data_state": "NoData",
"exec_err_state": "Alerting"
}
}
]
}
@@ -0,0 +1,44 @@
{
"apiVersion": 1,
"groups": [
{
"orgId": 1,
"name": "Group2",
"folder": "<dynamic>",
"interval": "1m",
"rules": [
{
"uid": "<dynamic>",
"title": "Rule3",
"condition": "A",
"data": [
{
"refId": "A",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0/0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"noDataState": "NoData",
"execErrState": "Error",
"for": "5m",
"annotations": {
"annotation": "test-annotation"
},
"labels": {
"label1": "test-label"
},
"isPaused": false
}
]
}
]
}
@@ -0,0 +1,49 @@
{
"name": "Group2",
"interval": "1m",
"rules": [
{
"expr": "",
"for": "5m",
"labels": {
"label1": "test-label"
},
"annotations": {
"annotation": "test-annotation"
},
"grafana_alert": {
"id": 3,
"orgId": 1,
"title": "Rule3",
"condition": "A",
"data": [
{
"refId": "A",
"queryType": "",
"relativeTimeRange": {
"from": 0,
"to": 0
},
"datasourceUid": "__expr__",
"model": {
"expression": "0/0",
"intervalMs": 1000,
"maxDataPoints": 43200,
"type": "math"
}
}
],
"updated": "2023-09-29T17:37:19Z",
"intervalSeconds": 60,
"version": 1,
"uid": "<dynamic>",
"namespace_uid": "<dynamic>",
"namespace_id": 0,
"rule_group": "Group2",
"no_data_state": "NoData",
"exec_err_state": "Error",
"is_paused": false
}
}
]
}
@@ -0,0 +1,31 @@
{
"name": "Group2",
"interval": "1m",
"rules": [
{
"for" : "5m",
"labels" : {
"label1" : "test-label"
},
"annotations" : {
"annotation" : "test-annotation"
},
"grafana_alert": {
"title": "Rule3",
"condition": "A",
"data": [
{
"refId": "A",
"datasourceUid": "__expr__",
"model": {
"expression": "0/0",
"type": "math"
}
}
],
"no_data_state": "NoData",
"exec_err_state": "Error"
}
}
]
}