If you know beforehand the acceptable range of values for a specific metric you can specify a filter by value (field_key
and field_value
in InfluxDB terminology) in the WHERE
part of the query.
This is also supported by Grafana in both the "text edit" and the "visual" modes. It's not obvious because Grafana only suggests tag names and values in the WHERE
autocomplete dropdown menu, but you can also type field_key
Enter, then choose an operator such as <
and type the number X
as the threshold above/below which all numbers will be filtered out as outliers.
For example, consider that you have a series reporting the latency of your internet connection and let's assume that anything above 200ms is an outlier or erroneous value from the sensor.
You can filter out the erroneous values with the following query. In "text edit" mode:
SELECT mean("value") FROM "ms" WHERE ("entity_id" = 'speedtest_ping' AND "value" < 200) AND time >= now() - 2d GROUP BY time(5m), "entity_id" fill(none)
In visual mode:
Here the field_key
is "value"
but you can filter by whatever field exists in your measurements.
I have noticed that for Grafana to preserve your filter when you switch between the visual and the text edit modes, you have to specify it within the parenthesis, e.g. like above: WHERE ("entity_id" = 'speedtest_ping' AND "value" < 200)