The first values of a variable is used in templating (Grafana 7.5.2)

When using templating in the alert messages, it seems the alert use the first values where the last ones are in fact the most interesting. How to use the most recent values?

Steps to reproduce:

  1. create a query generating a table with some values (timeseries)
  2. generate an alert with an error message containing a ${variable} based on on of the column of the table
  3. the message will be filled by the oldest value for this column, instead of the most recent one

The value in the printed error message will be “0.9” instead of “0.06”.

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

Grafana Open Source 7.5.2

  • What are you trying to achieve?

Print the last value

  • How are you trying to achieve it?

Using templating

  • What happened?

The oldest value is shown

  • What did you expect to happen?

Print the most recent value

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No errors.

  • Did you follow any online instructions? If so, what is the URL?