For few days now I’m trying to create alert when ratio produced to consumed messages is not equal to 1. I don’t want to do it based on prometheus due to each time service is restarted, counter is reseted also I don’t want to create gauge because I’d have to store count of produced messages somewhere in db. I decided to use logs stored in elasticsearch. Here the problem is that service which produces messages is logging to one elasticsearch and service which consumes them to another elastic. According to my knowledge it is impossible to create alret based on 2 queries.
I’m out of ideas how to approach this in other way around. Maybe I’m missing something or there is other way how to create alert like this based on 2 data sources?
You can use --Mixed-- data source then you can choose elasticsearch data source that you need, before it, build two elasticsearch data source for each index.
You can create multiple metric using mixed data source.
Other way,
First, choose the metricbeat, for example, then build the metric,
Second change the data source for heartbeat, for instance, then Add Query, choose the suitable datasource, then you can show in the single graph, multiple datasource.
Then, you can set the alert for each metric with specific conditions…
Thanks a lot for your detailed reply. Unfortunately, this does not help me since I want to do math between these two queries and not just check boolean conditions. I sincerely appreciate your reply though!
It is essentially firing when disk usage is above 75% AND also free space is less than 1TB. But when one of the hosts meets both conditions it seems that Grafana does not relate the two queries and send the alert for the host that matches both conditions. Instead it is sending me in the email all the hosts that match any of the two conditions.
Your alert should fire only when both conditions are met, but apparently it is not. Maybe it’s a bug or something that has been replaced with the new alerting.
If you use (or can upgrade to) Flux, then you can refer to Example 2 in this tutorial that alerts on 2 conditions. See Example 2.
Thanks i managed to create the two expressions and i see that final math expression works as expected. Though it seems that i can not create an alert based on an expressions (seems not supported with legacy alerting). Can you confirm this?