Procstat plugin returns process_name='pgrep' when the given pattern is not found

i am using the procstat plugin to gather information of a running process.
the process runs for 6hrs(0900-1500hrs) daily.
when the process is taken down procstat starts returning process_name as pgrep and the pid keeps changing.
the frequency of these pgrep process_names are not periodic also.

i am trying to create a column which will say running/not_running based on whether pid value is being received or not.

is this a intended behavior of procstat plugin to report the pid of the pgrep command when the actual process is not running or am i missing something here.
please help

It should indeed not occur for pgrep to return its own pid when the process is not running. Could you share a relevant part of your config (in code blocks please)

@Hipska thank you for responding

following the config:

[[inputs.procstat]]
  ## PID file to monitor process
  pattern = "/foodir/process_name/bin/process_name"

And what metric does telegraf provide when the process is not running? (For example by running telegraf with --test)

@neo1702 please also open an issue with the information requested by @Hipska!

@Hipska telegraf with --test option outputs only the internal* measurements and procstat_lookup. there is no procstat

@srebhan i have never done that before. can you help me with the process of it

Sure. You can open the issue here on the Telegraf Github project. You need a Github account for that I guess…
The link takes you to a form asking you for some things. For reproducing the issue on my side, the most important items are:

  1. The relevant config part, in your case the inputs.procstat section. Please redact sensible information before putting it there.
  2. The relevant part of the environment you run Telegraf in. How do you start Telegraf? Does it run on the machine or in a Docker container etc. Which version of Telegraf are you using? In your case you should mention that the process PID you are querying does not exist.
  3. The output of Telegraf, i.e. an error message, the log-lines relevant to the issue, but also the metric you see.
  4. The expected output/result.

Thank you in advance @neo1702!

Well, that is indeed the expected behaviour. Why or how do you think procstat is emitting a metric with the pid of pgrep?