Skip to content

procstat_lookup invalid tags #9961

@sajoupa

Description

@sajoupa

This issue is a follow-up from #9793, which wasn't completely fixed, and introduced a regression.

Relevant telegraf.conf:

[[inputs.procstat]]
  exe = "snapd"
[[inputs.procstat]]
  exe = "invalid"

System info:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

Steps to reproduce:

  1. Enable the procstat input plugin in telegraf 1.20.2, and specify the relevant selectors
  2. Observe the procstat_lookup measurement

Expected behavior:

  1. The lookup fields should be present as tags, e.g. "exe=apache2", even when the running measurement is 0 (i.e. the process is absent)
  2. The tags listed in https://github.com/influxdata/telegraf/tree/master/plugins/inputs/procstat for the procstat_lookup measurement should be (and only these):
  • exe
  • pid_finder
  • pid_file
  • pattern
  • prefix
  • user
  • systemd_unit
  • cgroup
  • win_service
  • result

Actual behavior:

  1. If the lookup didn't find any process, the "exe" (or "systemd_unit", etc.) tag will be absent
  2. If the lookup found processes, the process_name tag will be added

Additional info:

Telegraf <= 1.19.3:

sajoupa@maison:~$ /snap/telegraf/325/bin/telegraf --config ./telegraf.conf --test --input-filter=procstat | grep procstat_lookup
2021-10-20T12:20:46Z I! Starting Telegraf 1.19.3
> procstat_lookup,exe=invalid,host=maison,pid_finder=pgrep,result=success pid_count=0i,result_code=0i,running=0i 1634732447000000000
> procstat_lookup,exe=snapd,host=maison,pid_finder=pgrep,result=success pid_count=8i,result_code=0i,running=8i 1634732447000000000

Telegraf 1.20.0 (issue raised in #9793, fixed in #9808):

sajoupa@maison:~$ /snap/telegraf/333/bin/telegraf --config ./telegraf.conf --test --input-filter=procstat | grep procstat_lookup
2021-10-20T12:21:43Z I! Starting Telegraf 1.20.0
> procstat_lookup,host=maison,pid_finder=pgrep,result=success pid_count=0i,result_code=0i,running=0i 1634732504000000000 <- the "exe" tag disappeared
> procstat_lookup,host=maison,pid_finder=pgrep,result=success pid_count=8i,result_code=0i,running=8i 1634732504000000000 <- the "exe" tag disappeared

Telegraf 1.20.2:

sajoupa@maison:~$ /snap/telegraf/340/bin/telegraf --config ./telegraf.conf --test --input-filter=procstat | grep procstat_lookup
2021-10-20T12:09:57Z I! Starting Telegraf 1.20.2
> procstat_lookup,host=maison,pid_finder=pgrep,result=success pid_count=0i,result_code=0i,running=0i 1634731798000000000 <- the "exe" tag is still absent
> procstat_lookup,exe=snapd,host=maison,pid_finder=pgrep,process_name=snapd,result=success pid_count=8i,result_code=0i,running=8i 1634731798000000000 <- the "process_name" tag is present but it shouldn't

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/procstatbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions