Loki, how to group by host... And get the host in the alert message?

Ha, sorry but I cannot understand how to do that and tired to try to find it on youtube or elswhere.

I have an alert like this:

And I would like the alert occurs only when it’s 10 time on the same host.

And also, I would like to have the host name in the message send to rocket… Obviously this thing does not work:

Thanks in advance for your help.

Bonus question: in general, do you think the documentation is not enough from grafana?

1 Like

Hi! I think there are a couple of mistakes in this screenshot:

  1. I think you want to change your LogQL to do sum by (host) so the counts are summed for each host.
  2. Your Description is also incorrect as $A0 doesn’t exist. I’d recommend checking out Templating labels and annotations | Grafana documentation and Grafana Alerting: A guide to templating alert notifications.
  3. I would then recommend using a Reduce + Math expression instead of a Classic Condition. This will create one alert per host and make it easier to template the Description annotation.
1 Like

Haha, thank you.

I change for something like that:

sum by (host) (count_over_time({job=“myjob”}|~ " LONG :" [$__range]))

But cannot understand the next steps…

Hi! I’m not sure which next steps you’re having trouble with? Is it templating the Description annotation?

Yes it is!

I think the alert settings are not so bad now:

I cannot understand how to build a message in order to receive in rocketchat the name of the host.

Hi! I’m happy to help with that. Can you first take a look at my blog post on this topic Grafana Alerting: A guide to templating alert notifications to see if it helps? If you are still stuck I’d be happy to help.