[Solved²] Grafana + Influxdb query: get all procstat results from telegraf

I use telegraf for data collection and monitor a few processes with the procstat module.

At the moment i query the results manually in grafana from influxdb.

SELECT mean("cpu_usage") AS "telegraf" FROM "procstat" WHERE "exe" = 'telegraf' AND "host" = 'grafana' AND $timeFilter GROUP BY time($interval) fill(null)

I tried using … WHERE "exe" = '*' … in grafana but that does not return results.

Where is the error in the query?

Thank you very much for your help.

@lightonflux It sounds like you would like to return all the results. If you just remove the "exe" = 'foo' part of that query you should get what you are looking for.

Thanks for your answer.

It sounds like you would like to return all the results.

That is correct. But i need it to return the results separately. So every process has it’s one graph line.

SELECT mean("cpu_usage") AS "test_query" FROM "procstat" WHERE "host" = 'grafana' AND $timeFilter GROUP BY time($interval) fill(null)

This query only returns one result with accumulative cpu_usage of all processes monitored with procstat.

test_query is blue.

This is perfect, one query returns all results separately:

I don’t get how to do the same with procstat data.

@lightonflux Have you tried to GROUP BY "exe"?

1 Like

Thank you. That works very well.

 SELECT mean("cpu_usage") FROM "procstat" WHERE "host" = 'grafana' AND $timeFilter GROUP BY "exe",time($interval) fill(null)

Can you tell me how to alias it properly? What is the variable for the process names called? More importantly how do i look that up? The documentation for the procstat plugin does not mention anything like that.

At the moment it looks like this.

  procstat.mean {exe: kapacitor}

Just the process_name would be nicer.

@lightonflux The variable for the process name is exe. That is the tag key in Influx. Where is that output procstat.mean {exe: kapacitor} coming from? Is that from Grafana?

Yes that is the labels that grafana gives the graphs.

I tried to use $exe in grafanas “alias by” field, as well as AS in the query, but i always get “exe” or “$exe” as a string not value.

@lightonflux What version of grafana are you running? Can you share the settings on the Legend tab?

Grafana v4.3.2 (commit: ed4d170) 

Have you tried turning off As Table and To Right? On the grafana dashboards I’ve got access too this type of legend just has the tag values.

Does not change the label


In the query editor, set the “ALIAS BY” field to $tag_exe.

Grafana will automatically create a variable for grouped tags using $tag_<tag-key-name> that can be used in the “ALIAS BY” field on the query.


Thank you very much!