So the docs are pretty poor in this area tbh - so here is a working sample.
Json for an alert is below:- make sure to change the URL to post to which for me was http://grafana.staged-by-discourse.com/api/ruler/grafana/api/v1/rules/demo
demo was the name of the folder where the dashboard is
{
“name”: “Azure SQL - CPU %”,
“interval”: “1m”,
“rules”: [
{
“expr”: “”,
“for”: “5m”,
“labels”: {
“Customer”: “cloud adventure”,
“alertto”: “gregor”
},
“annotations”: {
“summary”: “Azure SQL - CPU %”
},
“grafana_alert”: {
“id”: 119,
“orgId”: 27,
“title”: “Azure SQL - CPU %”,
“condition”: “B”,
“data”: [
{
“refId”: “A”,
“queryType”: “Azure Monitor”,
“relativeTimeRange”: {
“from”: 600,
“to”: 0
},
“datasourceUid”: {{datasourceUid}},
“model”: {
“azureMonitor”: {
“aggregation”: “Average”,
“alias”: “{{ resourcename }} - {{ metric }}”,
“dimensionFilters”: ,
“metricDefinition”: “Microsoft.Sql/servers/databases”,
“metricName”: “cpu_percent”,
“metricNamespace”: “Microsoft.Sql/servers/databases”,
“resourceGroup”: “rg-grafanaresources”,
“resourceName”: “grafanadb/grafanadb”,
“timeGrain”: “auto”
},
“hide”: false,
“intervalMs”: 1000,
“maxDataPoints”: 43200,
“queryType”: “Azure Monitor”,
“refId”: “A”,
“subscription”: {{SubscriptionId}}
}
},
{
“refId”: “B”,
“queryType”: “”,
“relativeTimeRange”: {
“from”: 0,
“to”: 0
},
“datasourceUid”: “-100”,
“model”: {
“conditions”: [
{
“evaluator”: {
“params”: [
75
],
“type”: “gt”
},
“operator”: {
“type”: “and”
},
“query”: {
“params”: [
“A”
]
},
“reducer”: {
“params”: ,
“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”
}
}
]
}