Alertrule "invalid format of evaluation results for the alert definition" and not printing labels

Hi, I’m experiencing several issues with my API-generated alertrule in Grafana.

  1. The state in Grafana is normal, but when I open it, it shows an error. How can I fix that error?

  2. 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.

What version of Grafana do you use?
Can you show the state history of the rule?

The error looks strange. It says that the evaluation of the Loki query produced two dimensions that do not have any labels. This does not make any sense to me.

We use Grafana Cloud (steady)

I think the “__auto” legend is taken literally instead of filled with the real labels. Not sure on how to test it, but I’m going to try…

Try remove this field.