6

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?

schneida
  • 729
  • 3
  • 11
  • 37
  • Have you tried using "stack" at the display styles? Go Edit graph > display styles > multiple series and check "stack". I think your case is something like this: [http://play.grafana.org/?panelId=2&fullscreen](http://play.grafana.org/?panelId=2&fullscreen) – tgogos Dec 14 '15 at 16:02

1 Answers1

2

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:)
oori
  • 5,533
  • 1
  • 30
  • 37