Hi, I’m experiencing several issues with my API-generated alertrule in Grafana.
-
The state in Grafana is normal, but when I open it, it shows an error. How can I fix that error?
-
The labels resulting from my query are not shown in the summary where I want to print them. Maybe same issue as above maybe separated issue?
This is the JSON I use:
{
"ruleGroup": "SECRET",
"title": "[$(domain)] SECRET app down",
"uid": "$(domain)lokiappup",
"annotations": {
"summary": "{{ index $labels \"CustomerName\" }} App {{ index $labels \"app\" }} is not working on {{ index $labels \"Host\" }}",
"dashboard_url": "$(dashboardurl)"
},
"labels": {
"domain": "$(domain)",
"severity": "critical",
"team": "application",
"testenvironment": "false",
"environment": "PRD"
},
"folderUID": "$(folderuid)",
"for": "1m",
"condition": "tresholdA",
"noDataState": "OK",
"execErrState": "Error",
"isPaused": false,
"orgID": 1,
"data": [
{
"datasourceUid": "$(datasourceuid)",
"model": {
"datasource": { "type": "loki", "uid": "$(datasourceuid)" },
"expr": "sum by (app,CustomerName,Host)(count_over_time({app=~\"app1|app2\", level=\"error\"} |= `The system cannot find the file specified` [5m]))",
"instant": true,
"intervalMs": 1000,
"legendFormat": "__auto",
"maxDataPoints": 43200,
"range": false,
"refId": "metricA"
},
"refId": "metricA",
"relativeTimeRange": { "from": 600, "to": 0 }
},
{
"datasourceUid": "__expr__",
"model": {
"conditions": [
{
"evaluator": { "params": [ 0 ], "type": "gt" },
"operator": { "type": "and" },
"query": { "params": [ "C" ] },
"reducer": { "params": [ ], "type": "last" },
"type": "query"
}
],
"datasource": { "type": "__expr__", "uid": "__expr__" },
"expression": "metricA",
"intervalMs": 1000,
"maxDataPoints": 43200,
"refId": "tresholdA",
"type": "threshold"
},
"refId": "tresholdA",
"relativeTimeRange": { "from": 600, "to": 0 }
}
]
}
Can anyone help fixing my alertrule?
I’ve read something about reducing data, but not sure what to reduce. The result of the query is already what I want it to be.