Error when creating multidimensional alert rule on mssql

I get an error “format of evaluation results for the alert definition : frame cannot uniquely be identified by its labels: has duplicate results with labels {}”.
I don’t know what I’m doing wrong, I have a column with time, the values ​​are numeric, none of the columns have the forbidden name “metric”.
Grafana ver 9.2.4, MS SQL ver 2014


Welcome @wyrmic

These errors are tricky, and this is the first time I have seen it with MSSQL. Can you use a word other than “value” in your query? Or does MSSQL allow you to rename it in the query? This was the workaround in InfluxDB (using Flux).

The goal is to get expression B to show the two ID numbers (42940 and 1064) in query B, instead of the letter B shown in both panels. Once that is done, your multidimensional alert query should work.

Looking further into the Grafana documentation on MSSQL queries, I think you have to expand your line 3 to define two different values (call it value1 and value2…in the example below, they called it min_value and max_value.

Data frame result:

+---------------------+---------------------------+---------------------------+
| Name: time          | Name: value               | Name: value               |
| Labels:             | Labels: hostname=10.0.1.1 | Labels: hostname=10.0.1.2 |
| Type: []time.Time   | Type: []float64           | Type: []float64           |
+---------------------+---------------------------+---------------------------+
| 2020-01-02 03:05:00 | 3                         | 4                         |
| 2020-01-02 03:10:00 | 6                         | 7                         |
+---------------------+---------------------------+---------------------------+

Text

Example with multiple columns:

SELECT
  $__timeGroup(time_date_time, '5m'),
  min(value_double) as min_value,
  max(value_double) as max_value
FROM test_data
WHERE $__timeFilter(time_date_time)
GROUP BY $__timeGroup(time_date_time, '5m')
ORDER BY 1

SQL

Data frame result:

+---------------------+-----------------+-----------------+
| Name: time          | Name: min_value | Name: max_value |
| Labels:             | Labels:         | Labels:         |
| Type: []time.Time   | Type: []float64 | Type: []float64 |
+---------------------+-----------------+-----------------+
| 2020-01-02 03:04:00 | 3               | 4               |
| 2020-01-02 03:05:00 | 6               | 7               |
+---------------------+-----------------+-----------------+

Text

My source table contains data from multiple measurement points, row by row. That’s why I have to rotate it first (pivot). I tried to force column names but unfortunately it doesn’t help.


I wish I could help more. It seems like you have everything correct. Like I said earlier, these multidimensional alerts are tricky, esp. with data sources like MSSQL that are not as well documented or not as commonly used.

Maybe someone else will have a suggestion for what to tweak. If you do get it working, please post back.