I'm recording series such as memory_used with a couple of clients using the influxdb-java client into an InfluxDB database. The data look like this:
1449433668 19292838 client=clientA
1449433999 24448880 client=clientB
I can easily graph the memory usage grouped by tag using grafana, however I couldn't find a way to sum up the total memory consumption by all clients. When using avg(memory_used) or sum(memory_used) the values are way to large and fluctuate. I think this is because values for the same client may be summed up multiple times depending on the reported interval (which is not exactly the same).
How can I sum up the total memory consumption in this case? Should I code my clients to eg. always report values every 5 seconds and truncate the milliseconds?
You need to wrap the query with a sum() and group by client. for example:
SELECT SUM("memory_used") FROM (
SELECT mean("memory") AS "memory_used"
FROM "clients"."autogen"."memory"
WHERE time > now() - 1h
AND (“client"='clientA' OR "client"='clientA')
GROUP BY time(:interval:), "client" FILL(null)
) GROUP BY time(:interval:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With