Influxdb and grafana: howto create series that is the sum of two other series I have these three queries. They show the average upload speed of three different docker containers over time:



The difference() call is needed, because the data contains cumulative "bytes_sent" values, and it never decreases.

Here is an example of the output:



I would like to create a third series that shows the sum of the above three graphs. If I simply remove the WHERE condition the it won't work:



The reason for this is that mean() always precedes difference(), and the mean value of these independent cumulative sums is meaningless:



The correct solution would be to calculate the three difference values and add them together. But I don't know how to do this in grafana?

Obviously the very best solution would be to store the differences in the database in the first place. Unfortunately, I'm not the one who is sending the data so I can't do anything about it.
In theory, switch Grafana query editor to the raw mode and write a query where you use a subquery - outer query will just sum data precalculated by inner query:

SELECT SUM(field_from_main_query) FROM (
  &lt;your current Grafana query with GROUP BY time(10s) hostname&gt;
) GROUP BY time(10s)