Sum of aggregated (avg) values

Hi there,

I’m trying to understand how to do the sum of some series which are already aggregated.

I use following request in a graph which display in my example 5 server , and their associated RAM used.

SELECT mean(used) as used FROM "mem" WHERE host =~ /$server$/ AND $timeFilter GROUP BY time($inter), host ORDER BY asc

I’d like to do the sum of values displayed by this graph, and having a global RAM usage for my 5 servers.

I tried with something like this :
SELECT sum(used) as used FROM "mem" WHERE host =~ /$server$/ AND $timeFilter GROUP BY time(10s) ORDER BY asc

But it only works if I manually set a very short interval, to be sure that there is only one metric per server.
If I let normal interval, “sum” will add all metrics of each server (ex : if my interval is 5mns, with a nw metric every 10s, it will sum 6*5 = 30 metrics just for 1 server)

In fact I would like to do something like :

SELECT sum(mean(used)) as used FROM "mem" WHERE host =~ /$server$/ AND $timeFilter GROUP BY time(10s) ORDER BY asc

but which works :smiley:

How can I do that ?

thanks!
thomas