influxdata / influxdata/telegraf

[inputs.procstat] Reduce logging for missing pid files

Open
#16,206 5 comments 0 reactions 1 assignee Claimed by @mstrandboge View on GitHub
bug
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Relevant telegraf.conf

```toml
[[inputs.procstat]]
## PID file to monitor process
pid_file = "/opt/servicenow/mid/agent/work/midprod01.pid"
```

### Logs from Telegraf

```text
2024-09-18T15:07:44Z E! [inputs.procstat] Error in plugin: failed to read pidfile "/opt/servicenow/mid/agent/work/midprod01.pid": open /opt/servicenow/mid/agent/work/midprod01.pid: no such file or directory
```

### System info

Telegraf 1.32.1, Redhat 8.4

### Docker

N/A

### Steps to reproduce

1. Add process by pid file collect
2. Remove pid file
3. See the log in Error level

### Expected behavior

This use case is not illogical.
It therefore seems strange that with each collection in the absence of the pidFile a log line is added all the more in severity "Error".
This has the consequence of very quickly filling the FS or making important logs of other plugins disappear by rotation.
If the severity is appropriate, why in this case not generate an error when no process matches a filtering criterion?

I think the severity should be "Info".

### Actual behavior

An Error is generate for some normal use case.

### Additional info

The modification is here : https://github.com/influxdata/telegraf/blob/master/plugins/inputs/procstat/native_finder.go#L41
` pidString, err := os.ReadFile(path)
if err != nil {
return pids, fmt.Errorf("failed to read pidfile %q: %w", path, err)
}`
It should be :
` pidString, err := os.ReadFile(path)
if err != nil {
return pids, nil
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.