Query on postgresql on the Alert Rules tab does not work with non-numeric values on the result : Error Failed to evaluate queries and expressions: input data must be a wide series but got type long (input refid)

  • What Grafana version and what operating system are you using?

v9.4.7

  • What are you trying to achieve?

Making a an alert of the machines on the industrial field that has the duty_cycle > 80

  • How are you trying to achieve it?

I’m using a postgresql database with a table named ebbco_digital. On this table a have several different columns. The columns that I need are timestmap, machine_name, dutycycle. I’m trying to use this query:

SELECT duty_cycle, “timestamp”, machine_name FROM ebbco_digital WHERE $__timeFilter(timestamp) and duty_cycle is not null

After I’m trying to reduce it getting just the last value for each machine, and after trying to compare the duty_cycle value to make the alert

  • What happened?

I cannot use a query that return any column that is non-numeric such as machine_name so I get this error:

Error

Failed to evaluate queries and expressions: input data must be a wide series but got type long (input refid)
  • What did you expect to happen?

I expect to have a list like this

timestamp machine_name dutycyle
xxxx test_machine 80

To resume my query works without the machine name, but I would like to have the machine name to know in which machine I’m having the problem I also would like to send an email using the contact points and on the email I would like to send the machine name and the alert.