Failing to understand Influx arithmetic

Hi.

I have an InfluxDB table which receives one new value inserted every second. The value is always either 0 or 1.

Therefore adding up an arbitrary number of these values should always produce either 0 or a positive integer.

I’ve set up a query in Grafana to tell me the sum of these values over the past hour. Grafana’s query inspector shows me that it is doing:

q:“SELECT sum(“currentcalls”) FROM “mqtt_consumer” WHERE (“topic” = ‘PBX/Live’) AND time >= now() - 1h GROUP BY time(1h) fill(null)”

So, how is it possible for Grafana to tell me that the sum of these 3600 integer values is 1.3?

Thanks for any insight, or any pointers to where I’ve set up the query wrongly.

I’ve asked this on the Grafana list, and the response I got was “InfluxDB is doing all the calculations here”, which seems reasonable, therefore I’m asking here…

Antony.

Can you check using the command line influx ?

SELECT currentcalls FROM “mqtt_consumer” WHERE “currentcalls” != 0 and “currentcalls” !=1 and time >= now() - 1h limit 5

Can you check using the command line influx ?

I’ll wait until Grafana shows me something stupid again and then I’ll run that
query.

SELECT currentcalls FROM “mqtt_consumer” WHERE “currentcalls” != 0 and
“currentcalls” !=1 and time >= now() - 1h limit 5

Antony.

Good idea :slight_smile:

maybe you can add : and “topic” = ‘PBX/Live’ in the query to check as well

and if the query does not return any rows , it must be a Grafana problem

Marc

Right, Grafana shows me “1.5”, and your query displays nothing.

I’ll go back to the Grafana list :slight_smile:

Antony.