Telegraf > Procstat > E! Error in plugin [inputs.procstat]

==Configuration==

OS:

  • CentOS Linux release 7.4.1708 (Core)

PKGs:

  • influxdb-1.3.7-1.x86_64
  • grafana-4.6.2-1.x86_64
  • telegraf-1.4.3-1.x86_64

==Telegraf Configuration== /etc/telegraf/telegraf.conf
[[inputs.procstat]]
exe = "memcached"
prefix = “memcached”
[[inputs.procstat]]
exe = "ntpd"
prefix = “ntpd”

==Telegraf Output==

  • Plugin: inputs.procstat, Collection 1
    2017-12-12T18:49:22Z E! Error in plugin [inputs.procstat]: E! Error: procstat getting process, exe: [ntpd] pidfile: [] pattern: [] user: [] Error running /bin/pgrep: exit status 1
  • Plugin: inputs.procstat, Collection 1
    2017-12-12T18:49:19Z E! Error in plugin [inputs.procstat]: E! Error: procstat getting process, exe: [memcached] pidfile: [] pattern: [] user: [] Error running /bin/pgrep: exit status 1

***I’ve tried also in /etc/telegraf/telegraf.conf to have the below config but no graphs in Grafana then.

[[inputs.procstat]]
exe = "telegraf|.*"
prefix = “pgrep_svcs_process”

VS

[[inputs.procstat]]
exe = "telegraf|.*"
prefix = “pgrep_serviceprocess”

!!!
The point is to modify the /etc/telegraf/telegraf.conf and to collect all information for all processes and after this to be able to have the metrics in Grafana.

Is memcached running, what do you get when you run pgrep memcached?

*** pgrep ntpd**
*** pgrep memcached**

doesn’t return nothing and it’s clear that is a normal behavior of telegraf if a process is not up.


What are your recommendation in order to not have multiple definitions in “/etc/telegraf/telegraf.conf” like below:
[[inputs.procstat]]
exe = "memcached"
prefix = “memcached”
[[inputs.procstat]]
exe = "ntpd"
prefix = “ntpd”
.
.
.
etc

—===—===—
could I use something else like below for all processes:
[[inputs.procstat]]
exe = "telegraf|.*"
prefix = ?

What to do for the processes where “pgrep process” will not reveal nothing like: pgrep kibana, pgrep elasticsearch?
If I’ll try “pgrep -u root, kibana; pgrep -u root, elasticsearch” then will be output there for process.
All apps are installed under root permission…

I would use the former, though generally I prefer:

[[inputs.procstat]]
  exe = "memcached"
  name_override = "memcached"

I’ve never used telegraf|.*, I looks like it would just match everything in which case it seems simpler to just use exe = ".*". If you collect all the processes in one plugin then it won’t be helpful to set a prefix. There is another more important issue with collecting all processes though: in order to avoid conflicts you must use pid_tag = true and due to the number of pids created on a normal system you will end up creating many series which add lot’s of strain on the Database. You might be able to solve this with a short retention policy, but you are better off monitoring a limited number of long running processes with this plugin.

1 Like

Thank you for your approach.
One little mention because I’m searching a solution and maybe you have a better suggestion.

For example if I want to collect metrics with Telegraf for:

  • node_exporter
  • Kibana

/etc/telegraf/telegraf.conf
[[inputs.procstat]]
exe = "node_exporter"
name_override = “node_exporter”
[[inputs.procstat]]
exe = "kibana"
name_override = “kibana”

I have a question that for the moment I don’t have a solution.
By default Telegraf will do a $ pgrep kibana, $ pgrep node_exporter but the thing is that if you have the below situation then it will be not relevant.

[root@server ~]# systemctl status kibana
● kibana.service - Kibana
Loaded: loaded (/etc/systemd/system/kibana.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2017-12-12 21:42:42 EET; 11h ago
Main PID: 4206 (node)
CGroup: /system.slice/kibana.service
└─4206 /usr/share/kibana/bin/…/node/bin/node --no-warnings /usr/share/kibana/bin/…/src/cli -c /etc/kibana/kibana.yml

[root@server ~]# systemctl status node_exporter
● node_exporter.service - Node Exporter
Loaded: loaded (/etc/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-12-07 17:24:17 EET; 5 days ago
Main PID: 581 (node_exporter)
CGroup: /system.slice/node_exporter.service
└─581 /root/Prometheus/node_exporter-0.15.0.linux-amd64/node_exporter

[root@server ~]# pgrep node
581
4206
[root@server ~]# pgrep node_exporter
581

***How to colect metrics for Kibana only?

Solution could be below?
===========PID file?============
[[inputs.procstat]]
** exe = “kibana”**
** name_override = “kibana”**
** pid_file = “/var/run/kibana.pid”**

That should work, also in 1.5.0 (being released very soon) you will be able to select all the processes for a systemd service file:

[[inputs.procstat]]
  systemd_unit = "kibana.service"
  name_override = "kibana"
1 Like

Many thanks, I’ll implement in this way.

E! Error parsing /etc/telegraf/telegraf.conf, line 1937: field corresponding to systemd_unit' is not defined in*procstat.Procstat’

It seems that the telegraf will not start.

Make sure you have Telegraf 1.5.0-rc2 or newer if you want to use this option, the final version will be released soon.

1 Like