Alerting object data as string

In an alert rule, I use a query expression that returns a table. Is it possible to pass somehow this information as a variable in the ‘Description’ field?

I tried using {{ $values.QueryStepName.Value }}. This expression returns a NaN value…

@imanolpadillo Welcome to the Grafana forum. Can you post the full alert that uses this query (all parts, i.e. query, expression, math, etc.)?

Hi,

First of all, thanks for your answer. In following picture you can see the “query and alert condition”. There are 3 steps:

  • Step 1 (Myquery): This is a dummy query that returns a table.
  • Step 2 (ItemNumber): This step counts the number of rows of the table generated in step 1.
  • Step 3 (ActivateAlarm): This conditions activates the alarm if the result of step 2 is equal or greater than 1.

In case that the alarm is activated, I would like (somehow) to send the information generated in Step1. I tried it using the following expression {{ $values.Myquery.Value }}, but it does not work…
SummaryAndAnnotations

@imanolpadillo
Please post the full output when you click Preview Alerts.

Also (and I am not sure if this matters), for Step 3 of your alert, I would use $B >= 1

I renamed the steps to “A”, “B” and “C”.

The alarm output for {{ $values.A.Value }} is “no value”:

But I expect to receive (somehow) this information:

1 Like

On the alert setup screen, scroll down and click the blue preview button and post the output here.

I see that there is only information for steps B and C (which are expressions), but there is no info for step A (which is SQL query)

Just to confirm, you want this data in your alerts…
image

However, I believe you can only get, for example, the last row in the table, or the average of the past 10 readings, or some other aggregation of the table.

In your alert text, what is most important from the table in query A above? The last row?

I can see that it is possible to get for example the last value:

And that works:

However I suppose that it is not possible to get all the list of values… In any case thank you very much for your help

My understanding with Grafana Unified Alerting is that everything must be reduced to a single value in order to be alerted on. In your case, Query A returns a table with, what, 10 rows? It could be 100 or 1000 rows. In any event, the idea is that the alerting text cannot contain 10 (or 100 or 1000) datapoints coming from your table.

If I am wrong, maybe someone else can chime in.

Grant is 100% correct here. Grafana does not allow templating of the query result, just the reduced value and the result of Math expressions.