Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inputs.win_perf_counters] skip PdhCstatusNoInstance error #14557

Closed
hiroshi-iim opened this issue Jan 9, 2024 · 2 comments · Fixed by #14570
Closed

[inputs.win_perf_counters] skip PdhCstatusNoInstance error #14557

hiroshi-iim opened this issue Jan 9, 2024 · 2 comments · Fixed by #14570
Labels
feature request Requests for new plugin and for new features to existing plugins

Comments

@hiroshi-iim
Copy link

Use Case

I plan to collect processes metrics on Windows host using configuration like below.

[agent]
  round_interval = true
  precision = "5s"
  interval = "5s"

[[inputs.win_perf_counters]]
  UseWildcardsExpansion = true

[[inputs.win_perf_counters.object]]
  UseRawValues = true
  ObjectName = "Process"
  Instances = ["OUTLOOK*", "python*"]
  Counters = [
    "ID Process",
    "% Processor Time",
]    

[[outputs.file]]
  files = ["stdout"]
  data_format = "csv"
  csv_timestamp_format = "2006-01-02T15:04:05Z07:00"

I tested this configuration with the following steps.

  1. Start outlook and run python -c "while True: i=1".
  2. Then start telegraf with above configuration.
  3. Wait until telegraf outputs records for 1st interval.
  4. Then Quit outlook.

Expected behavior

Telegraf continues to output records of running processes (matching "python*" in this case).

Actual behavior

Telegraf outputs error logs shown below and stops to output records until counters are refreshed.

E! [inputs.win_perf_counters] Error in plugin: error during collecting data on host "localhost": error while getting value for counter "\\\\{my computer name}\\Process(OUTLOOK)\\ID Process": The specified instance of the performance object was not found.

Additional info

I temporarily modified isKnownCounterDataError function to return true when errorcode is PdhCstatusNoInstance and ran same senario. In the case telegraf outputs warn logs shown below but continues to output records of python instance which has consistent value.

W! [inputs.win_perf_counters] Error while getting value for counter "\\\\{my computer name}\\Process(OUTLOOK)\\ID Process", instance: OUTLOOK, will skip metric: The specified instance of the performance object was not found.

Actually I have to set Instances = ["*"] in real case. In that case there are more chances to see PdhCstatusNoInstance error.

This is derived from #14486

@powersj
Copy link
Contributor

powersj commented Jan 12, 2024

@hiroshi-iim

Thanks for filing the second issue.

My only open question is if we should make this change opt-in, via a config setting. I don't think there is any harm in adding this and users would only be getting additional data, not less.

I have put up #14570 which incorporates both PRs. Could you confirm it gets the data for you?

Thanks!

@powersj powersj added the waiting for response waiting for response from contributor label Jan 12, 2024
@hiroshi-iim
Copy link
Author

Hi @powersj

I don't think there is any harm in adding this and users would only be getting additional data, not less.

I completely agree with you.

I have put up #14570 which incorporates both PRs. Could you confirm it gets the data for you?

The new module works perfectly as expected.

Thanks!

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Jan 15, 2024
powersj added a commit to powersj/telegraf that referenced this issue Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants