I’m trying to automate alert creation, but I am stuck on getting the request JSON right. I’ve already read the docs, for AlertQuery, but there’s no documentation for what the "model"
field should contain.
This is the JSON I have
{
"annotations": {
"summary": "There was a problem"
},
"condition": "C",
"data": [
{
"datasourceUid": "ae6mk8l28qosgd",
"model": {
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "ae6mk8l28qosgd"
},
"editorMode": "code",
"format": "time_series",
"intervalMs": 1000,
"maxDataPoints": 43200,
"rawQuery": true,
"rawSql": " SELECT timestamp AS time, COUNT(DISTINCT(group, code)) AS value FROM errors WHERE $__timeFilter(timestamp) GROUP BY timestamp;",
"refId": "A"
},
"queryType": null,
"refId": "A",
"relativeTimeRange": null
},
{
"datasourceUid": "__expr__",
"model": {
"conditions": [
{
"evaluator": {
"params": [
0,
0
],
"type": "gt"
},
"operator": {
"type": "and"
},
"query": {
"params": []
},
"reducer": {
"params": [],
"type": "avg"
},
"type": "query"
}
],
"datasource": {
"name": "Expression",
"type": "__expr__",
"uid": "__expr__"
},
"expression": "A",
"intervalMs": 1000,
"maxDataPoints": 43200,
"reducer": "max",
"refId": "B",
"type": "reduce"
},
"queryType": null,
"refId": "B",
"relativeTimeRange": null
},
{
"datasourceUid": "__expr__",
"model": {
"conditions": [
{
"evaluator": {
"params": [
29,
0
],
"type": "gt"
},
"operator": {
"type": "and"
},
"query": {
"params": []
},
"reducer": {
"params": [],
"type": "avg"
},
"type": "query"
}
],
"datasource": {
"name": "Expression",
"type": "__expr__",
"uid": "__expr__"
},
"expression": "B",
"intervalMs": 1000,
"maxDataPoints": 43200,
"refId": "C",
"type": "threshold"
},
"queryType": null,
"refId": "C",
"relativeTimeRange": null
}
],
"execErrState": "Error",
"folderUID": "bea6zr80zxlvke",
"for": 0,
"id": null,
"isPaused": null,
"labels": null,
"noDataState": "OK",
"notification_settings": null,
"orgID": 1,
"provenance": null,
"record": null,
"ruleGroup": "MyGroup",
"title": "Test Alert",
"uid": null,
"updated": null
}
I keep getting this response:
{
"message": "invalid object specification: type should not be an empty string",
"traceID": ""
}