Invalid format of evaluation results for the alert definition : frame cannot uniquely be identified by its labels: has duplicate results with labels {}

I also have this problem. I’m using a PostgreSQL data source with Grafana Cloud v8.3.5, and my data looks like this:

time device_id value
2022-02-01 11:06:00 device_01 0
2022-02-01 15:21:45 device_14 1
2022-02-01 15:23:12 device_19 0
2022-02-01 15:23:22 device_13 0
2022-02-01 15:23:48 device_02 1

I want to set up alerts to be notified e.g. when a device value changes to 1.

As far as I understand, if I use a classic condition, the alert applies to any device, in aggregate. Instead, I want a multi-dimensional rule in order to “generate a separate alert for each series” (as per the documentation).

I keep getting invalid format of evaluation results for the alert definition : frame cannot uniquely be identified by its labels: has duplicate results with labels {} no matter what I try. I’ve tried no expression, various combinations of math and reduce expressions, as well as the workaround of using both: Grafana 8 alerting - multiple series values - #3 by michaelosthege

This is reproducible even with “wide” sample data without “holes”:

SELECT * FROM (VALUES
  (NOW() - INTERVAL '1 minute', 1, 2),
  (NOW(), 3, 4)
) t1 ("time", c1, c2)

Am I misunderstanding something about the data format?