First steps with alerting, alert if value higher than

What I want to achieve, functionally:

Have an alert sent out when the usage on one of my phases (3) is over 20A for 10/20/30s.
Why? To give me a chance to lower my power consumption before the main fuse blows. I have an electric car and load balancing on the EVSE is (not) yet working, so this will have to do for a while.

Bonus would be that Grafana could trigger an HTTP URL to lower the car charger, but that’s maybe later.

I am from the old ages and I can’t seem to get the new way of Flux, but for now everything I wanted to get working works except for alerting.
I got to the alerting dashboard and thought “well, this can’t be that hard” but I get some errors:

Why does it show Alert condition red when I do a preview although the Amps are well below 20?
What is wrong with the alert since it shows health yellow?

Hi @homemonitor,
Can you try removing query B (Threshold) and then click Add expression and select:

Function: mean
Mode: Drop Non-numeric values 
Input: A

and after that add query C Threshold:

Input: B
Is above: 20


My query:

from(bucket: "test")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "cpu")
  |> filter(fn: (r) => r["_field"] == "usage_user")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")


Best regards,

1 Like

@homemonitor Because there were so few examples of creating alerts using Flux queries, I wrote up this tutorial. Maybe it will help you out.

1 Like