I have configured an alert rule
How can I make the message display only the latest status?
Hi! Can you explain what you are trying to achieve? Without knowing more about the intended use-case, this isn’t how Grafana Alerting is intended to be used. What you have here are not older/newer states, but instead separate alerts. I would recommend removing the datetime label from your query because you are actually creating new alerts for each
label
every time the rule is evaluated. Instead, you should be re-using any existing alerts for the same label
. You can do that by removing now()
from the SQL query.
now() used for example. In this case, how should additional information be displayed in the message?
For example: Show an alert if the number of transactions > 5, display the amount of these transactions in the message
I have two queries:
A is used with a Threshold expression:
SELECT COUNT(1) FROM test;
B is used to get the text, comma separated:
SELECT 1, string_agg(host, ', ') as hosts FROM test;
I then have an annotation with the following template:
{{ with $values.B }}{{ index .Labels "hosts" }}{{ end }}
and this gives me the hosts
column from B.
I used PostgreSQL here, use whatever equivalent to string_agg
is in MySQL.