Is it possible to have labels in Loki managed alerts summary/description?

Hello everyone;

I have several Loki-managed alerts, as I’ve understood from the documentation these alerts expressions must be in the format of either rate() or count_over_time(), obviously when using this format the {{ $value }} variable used in the alert’s summary/description returns the value of count_over_time() and rate().

I have two questions:

1- Is it possible to use expressions without rate or count_over_time? When I use them the state of that alert is either error or nodata but I want to know is there any workaround or solution for this?

2- The reason I need the previous question is that being notified that there are some error or warning logs is not enough for me, I want to be able to pass some variables such as uid & iid (VM instance ID). Since these labels change dynamically I can’t write a static summary for them hence, is there any way to use these labels as variables such as {{ $labels.uid }}?

Any help is appreciated, thanks in advance.

I’m having a similar issue, did you ever get this working?

We’re using the AWS Lambda promtail to forward lambda logs from AWS to a Grafana Labs/Cloud Loki instance, I’d like to use a label of: {{ $labels.__aws_cloudwatch_log_group }}label in my alerts to give the receiver some context around which lambda is firing the alert. My query is broad to find things like a Lambda timeout, I don’t want to have to create a query/alert per function just to inject this information… surely it’s possible?

Hello Keegs, unfortunately, I was unable to make it work, we abandoned the task and are currently in the process of developing some sort of middleware for it.