I am tracking the energy consumption of my house in Prometheus, but occasionally, the device that reads the meter values gets disconnected from the network. To be notified about that, I have created an alert that fires on this condition:
changes(energy_consumed[$__range]) < 1
It is implemented by a query changes(energy_consumed[$__range])
, followed by a reduce to ‘last’ and a threshold ‘< 1’.
Now I moved into a new house, with solar panels. On a sunny day, we don’t consume any power from the grid, which causes the alert to fire: the metric is always zero, so there are no changes.
To address this, I wanted to sum the changes, like this:
changes(energy_consumed[$__range]) + changes(energy_produced[$__range]) < 1
But that results in the following error: 2 items dropped from union(s). Then I tried adding the values in PromQL, like this:
changes(energy_consumed[$__range]) + changes(energy_produced[$__range])
But that gives an empty query result.
What is the right way to get this done?
Thanks in advance!
Bert