can anyone provide me the JSON request body for creating an Alert rule via HTTP API?
I followed this link-https://community.grafana.com/t/creating-alert-rule-via-http-api/63961
I am using api/ruler/grafana/api/v1/rules/Alerts this API.
My request body :
{
“name”: “Azure SQL - CPU2 %”,
“interval”: “1m”,
“rules”: [
{
“expr”: “”,
“for”: “5m”,
“labels”: {
“Customer”: “cloud adventure”,
“alertto”: “gregor”
},
“annotations”: {
“summary”: “Azure SQL - CPU %”
},
“grafana_alert”: {
“orgId”: 1,
“title”: “Azure SQL - CPU2 %”,
“condition”: “B”,
“data”: [
{
“refId”: “A”,
“queryType”: “InfluxDB”,
“relativeTimeRange”: {
“from”: 600,
“to”: 0
},
“datasourceUid”: “AGaZLdanz”,
“model”: {
“InfluxDB”: {
“aggregation”: “Last”,
“Bucket” : “telegraf”,
“_measurement”:“cpu”
},
“hide”: false,
“intervalMs”: 1000,
“maxDataPoints”: 43200,
“queryType”: “InfluxDB”,
“refId”: “A”
}
},
{
“refId”: “B”,
“queryType”: “Classic condition”,
“relativeTimeRange”: {
“from”: 0,
“to”: 0
},
“datasourceUid”: “-100”,
“model”: {
“conditions”: [
{
“evaluator”: {
“params”: [
60
],
“type”: “nv”
},
“operator”: {
“type”: “and”
},
“query”: {
“params”: [
“A”
]
},
“reducer”: {
“type”: “last”
},
“type”: “query”
}
],
“datasource”: {
“type”: “expr”,
“uid”: “-100”
},
“hide”: false,
“intervalMs”: 1000,
“maxDataPoints”: 43200,
“refId”: “B”,
“type”: “classic_conditions”
}
}
],
“intervalSeconds”: 60,
“rule_group”: “Azure SQL - CPU %”,
“no_data_state”: “NoData”,
“exec_err_state”: “Alerting”
}
}
]
}
but the query is showing as blank in the alert rule.