Alerting when two metrics are not equal

Hi, I’m trying to define alerting condition if count of Metric A does not match count of Metric B. As you can see in the below attached image, the count is unequal - (metric A:3 and metric B:4) and that is when I need to trigger an alert. I’m using Elasticsearch datasource and I want to do something like:
WHEN count() query(A,5m,now) IS ABOVE “query B”
WHEN count() query(A,5m,now) IS BELOW “query B”

  1. Currently, it only takes numerical values. Is there a way to do it in some other way?
  2. Also, I get the error message datasource does not support alerting queries even though I’m using elasticsearch. Is there a reason for that?
  3. I’ve already bucketed the datapoints in Metric for 1h. Still why do I need to
    specify the timerange in alert condition? I need alerting for the same 1h period.

Thank you!

It looks like you need to upgrade your Grafana instance, Elasticsearch alerting support was added in 5.2.

That said, there is no support in Grafana for alerts based on comparisons between 2 different queries, you’ll need to figure out how to express your logic in a single query. In most TSDBs you can achieve what you’re looking for by subtracting the values and alerting if the result is not 0, but I’m not sure if that’s possible in Elasticsearch.

The alert query time range specifies the time period that the alert will query for, in the same way as the time range on the dashboard specifies the time range it will display.