Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining a total of two series of data from InfluxDB in Grafana

I am perplexed at this point. I spent a day or three in the deep end of Influx and Grafana, to get some graphs plotted that are crucial to my needs. However, with the last one I need to total up two metrics (two increment counts, in column value). Let's call them notifications.one and notifications.two. In the graph I would like them displayed, it would work well as a total of the two, a single graph line, showing (notifications.one + notifications.two) instead of two separate ones.

I tried with the usual SELECT sum(value) from the two, but I don't get any data from it (which does exist!). There is also merge() mentioned in the documentation of Influx, but I cannot get this to work either.

The documentation for merge requires something like:

SELECT mean(value) FROM /notifications.*/ WHERE ...

This also, comes back as a flat zero line.

I hope my question carries some weight, since I have far from enough knowledge to convey the problem as good as possible.

Thank you.

like image 991
Marlon van der Linde Avatar asked Nov 30 '15 11:11

Marlon van der Linde


1 Answers

With InfluxDB 0.12 you can write:

SELECT MEAN(usage_system) + MEAN(usage_user) + MEAN(usage_irq) AS cpu_total 
  FROM cpu
  WHERE time > now() - 10s 
  GROUP BY host;

These features are not really documented yet, but you can have a look at supported mathematical operators.

like image 109
Tombart Avatar answered Sep 28 '22 05:09

Tombart