Hi I’m building a stat panel in Grafana to track the count of low gas trips. This is a binary point and I’m wondering if there is a way to filter the value of the point such that I only count when the value is 1 (i.e. the point trips). My base query below:
Count(FILTER ActiveMeasurements WHERE PointTag = ‘LOW_GAS’)
Hi,
You can try something like Count(IncludeRange(0.5, 2,FILTER ActiveMeasurements WHERE PointTag = ‘LOW_GAS’))
This would exclude any values below 0.5
and above 2
1 Like
Great! This is what I was looking for! I actually realize now that this type of point maintains a value of 1 the entire time that the point is tripped. In actuality, I would be counting the instances when the point switches from 0 to 1. Would it be possible to nest aggregate functions in Grafana? For example:
Count(IncludeRange(-0.5, -2, Difference(FILTER ActiveMeasurements WHERE PointTag = ‘LOW_GAS’)))
You have a few options here, They have slightly different performance implications and may behave differently in edge cases (e.g. 0 switches to 1 before your time range starts, but switches back post time range).
You can certainly nest aggregated functions, I would recommend one of the following:
ExceedsAt
Difference
Noting that the ExceedsAt
will return more information, inlcuding the duration of the trip etc.
1 Like