telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Procstat should support multiple search criteria

Open kohonen opened this issue 6 years ago • 6 comments

Relevant telegraf.conf:

[[inputs.procstat]]
  exe = "java"
  user = "logstash|elasticsearch"
  interval = "1m"
  pid_tag = true

[[inputs.procstat]]
  exe = "influxd"
  user = "influxdb"
  interval = "1m"
  pid_tag = false

[[inputs.procstat]]
  exe = "node"
  user = "kibana"
  interval = "1m"

System info:

telegraf-1.11.1-1.x86_64 influxdb-1.7.7-1.x86_64

CentOS Linux release 7.6.1810 (Core)

Steps to reproduce:

the telegraf github page show way more fields and tags for the procstat_lookup measurement than we can see. tried to change pid_tag = true/false, no success

Expected behavior:

we need at least the 'user' tag in order to differentiate between the 2 java processes (elasticsearch+logstash)

procstat_lookup
tags:
- exe
- pid_finder
- pid_file
- pattern
- prefix
- user
- systemd_unit
- cgroup
- win_service
- result

fields:
- pid_count (int)
- running (int)
- result_code (int, success = 0, lookup_error = 1)

Actual behavior:

> select * from procstat_lookup
name: procstat_lookup
time                 exe     host               pid_count pid_finder result  result_code running
----                 ---     ----               --------- ---------- ------  ----------- -------
2019-07-26T08:26:00Z influxd MYHOSTNAME 1         pgrep      success 0           1
2019-07-26T08:26:00Z java    MYHOSTNAME 2         pgrep      success 0           2
2019-07-26T08:26:00Z node    MYHOSTNAME 1         pgrep      success 0           1

kohonen avatar Jul 26 '19 08:07 kohonen

I should mention that the plugin right now only supports lookup using a single search criteria, so if you set both exe and user only exe is taking effect. Lookup on multiple attributes would be a good feature request though.

On the tags though, we should update the plugin so that the lookup tags on procstat_lookup match with the procstat measurement.

danielnelson avatar Jul 26 '19 21:07 danielnelson

Tried fixing this today and it ended up being a result of procstat using only one search criteria. I'm going to convert this issue into a feature request for performing a logical AND across all the set search terms.

danielnelson avatar Aug 22 '19 05:08 danielnelson

hello?

mossad-zika avatar Aug 07 '22 11:08 mossad-zika

It would be nice to have this filtering capability.

tguenneguez avatar Feb 05 '24 12:02 tguenneguez

Hello,

I'm trying to implemente something to be able to search process by 2 criterias. But after analysing how the plugin work, i realise that it doesn't search process with the same criteras if you are un natif mode or with pgrep. In detail :

Mode exe pattern
pgrep /proc/(pid)/stat (max 16 chars) /proc/(pid)/cmdline (max 4096 chars)
natif link /proc/(pid)/exe /proc/(pid)/cmdline

I would like do a good implementation of this feature without breaking change but it's verry difficult. pgrep isn't good for long args commands like java. native isn't good for script because the exe isn't the process name. There is a confusion between the exe and the process name. The natif mode should search for exe in /proc/(pid)/stat not in the /proc/(pid)/exe...

I think that this feature will do :

Mode exe name pattern
pgrep /proc/(pid)/stat (max 16 chars) /proc/(pid)/stat (max 16 chars) /proc/(pid)/cmdline (max 4096 chars)
natif link /proc/(pid)/exe /proc/(pid)/stat (max 16 chars) /proc/(pid)/cmdline

Thanks for ideas to do a good feature... Thomas

tguenneguez avatar Feb 06 '24 14:02 tguenneguez

Hello, I have the same problem with telegraf. Could you develop a new feature? Thanks

julien64140 avatar Feb 06 '24 14:02 julien64140

Same issue here, i am waiting for a release.

reminder84 avatar Feb 19 '24 08:02 reminder84