[SOLVED] Measurements in FROM clause shown in single drop down list as big strings - how to split them up?


#1

Dear community,

currently I try to set up Grafana to monitor our NAS and Smart Home Server. I already get data from the hosts but the measurements come in one string like

 servers.obelix.aggregation-cpu-average.percent-user

So, when trying to select the FROM clause of the InluxDB query, I get a huge list which all measurements at once which of course don’t fit in the drop down list.
The little video in chapter ‘Query Editor’ of InfluxDB data source guide makes me believe that there is a better solution - means somehow I should be able to achieve a configuration where I first select

servers.obelix

in the next drop down the metric

 aggregation-cpu-average

and finally the value

percent-user    

Further more, currently I do a

SELECT mean("value") 

but it would be better to have

SELECT mean(“percent-user”)

…this way I could sum percent-user and percent-system as I am interested in the total CPU load only.

Environment:

  • CollectD on several hosts running on ubuntu, armbian or freebsd
  • CollectdD currently has cpu, aggregation and graphite plugin enabled
  • Using CollectD graphite plugin to send metrics to Grafana server
  • Grafana and InfluxDB run on a VM with Ubuntu Linux 16.04.5
  • InfluxDB 1.7.1
  • Grafana 5.4.0-beta1

I know, this is probably a beginners question - but it would be great if still was somebody out here to help me with some hints.
Currently I not even know if I have to conjure this in CollectD, InfluxDB or Grafana :hushed:

Thanks a lot for your help!

Kind regards,
Michael


#2

Well, thanks for the hints. Took me two evenings but now I figured it out:

Templates in InfluxDB have to be used for parsing Graphite metrics and extract tags as well as fields. Most important: as only tags are indexed this will improve performance of the queries.

In file /etc/influxdb/influxdb.conf I have added the following entries:

 [data]
     engine = "tsm1" 

wich enabled the possibility to have the metric name as field name instead of the field ‘value’
and

 templates = [
     "servers.* .host.measurement.field",
 ]

where servers. acts as initial filter and the second string extracts the tags from the measurement string.

So finally I was able to query the metric mentioned at the beginning of my post with the following InfluxDB query:

 SELECT mean("percent-user") 
   FROM "aggregation-cpu-average" 
   WHERE ("host" = 'obelix') 
     AND $timeFilter 
   GROUP BY time($__interval) fill(null)