Create Math Expression Based on 2 Reduce Expressions

Hey folks,

Might be a simple question for you all - just curious how do we create a Math Expression for two different Reduce Expressions?

Below is a screenshot of 2 Difference Reduce Expressions

And Math Expression i am looking at is
$C > 4 || $D > 5

Where at any point if C is greater than 4 then alert should be triggered OR if D is greater than 5 then alert should be triggered.

I’ve tried this approach but it seems to be an Invalid Expression.

1 Like


Yes, it should be possible. Here is an alert that I have:

Two queries (A and B):

Two reduce expressions (C and D) and one math expression (E) that uses C and D

Thanks @grant2,

in your Math Expression is slightly different from mine. I am basically validating two queries with different conditions but with an OR Operator in between. I’ve shared a screen shot where it should return data as condition of D is satisfied

Does this make any difference?

${C} > 4 || ${D} > 1

No, Still No Data


Just for proof of concept, I put your formula into my Math expression (E) and it indeed worked.

I have no idea why yours is not returning any values. What is your datasource?

That’s weird.

my Datasource is “Google Cloud Monitoring”


This is just a crazy suggestion, but does anything in Expression E change if you select Stat:


No, all of them show NoData …

Is this something needs to be reported as a Bug for a Google Cloud Monitoring Datasource?

I guess it depends. Does a simpler formula yield any results, e.g.

We’ve met with the same problem. At last we handle it at query step using code $a / $b and it works

We’ve tried and it does not work in condition of two different queries and works well with only one query

In my case, the final math expression containing two conditions (using the || operator) does work for alerting. The only difference I can see is that I am using InfluxDB.

I’m using prometheus

I believe at this time we need someone from Grafana Team to Officially confirm if this is something which is expected to be looked at @mattabrams / @melori.arellano - What do you suggest next steps should be?

Thanks in advance!

In my case with two reduce expressions (C and D) it only show alerts about the first reduce expression…
I tried with
${C} < 3600 || ${D} < 3600 (alert based on C)
$C < 3600 || $D < 3600 (alert based on C)

The craziest thing is that it always take the $C reduction into account, no matter if I use
$D < 3600 || $C < 3600