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

perfmon - remove negative counter value errors from the event output #18361

Merged
merged 4 commits into from
May 12, 2020

Conversation

narph
Copy link
Contributor

@narph narph commented May 7, 2020

What does this PR do?

  • ignores PDH_CALC_NEGATIVE_VALUE and PDH_INVALID_DATA type errors from the event output
  • adds cstatus value in the debug information

Why is it important?

When collecting a high number of counters values seems that for specific processes the counter values retrieved are negative and the win32 api returns the error:

0x800007D8 (PDH_CALC_NEGATIVE_VALUE) | A counter with a negative value was detected.

or

0xC0000BC6 (PDH_INVALID_DATA) | The data is not valid. with cstatus 0xC0000BBA (PDH_CSTATUS_INVALID_DATA) | The returned data is not valid.

Which means the counter was successfully found, but the data returned is not valid. This error can occur if the counter value is less than the previous value. (Because counter values always increment, the counter value rolls over to zero when it reaches its maximum value.) Another possible cause is a system timer that is not correct.

These errors do not cause the application to run unsuccessfully and the following calls return a positive value.
These types of errors are still logged as debug messages.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Create a perfmon configuration with a high number of perfmon counters including Process object counters since the errors are encountered only at that level and run the perfmon metricset with a small interval.

Related issues

Logs

	Line 236493: 2020-05-07T18:18:27.118+0200	DEBUG	[perfmon]	perfmon/data.go:51	Counter value retrieval returned	{"error": "A counter with a negative value was detected.", "cstatus": "A counter with a negative value was detected.", "perfmon": {"query": "\\\\DESKTOP-RFOOE09\\Process(SearchFilterHost)\\IO Other Bytes/sec"}}
	Line 236494: 2020-05-07T18:18:27.144+0200	DEBUG	[perfmon]	perfmon/data.go:51	Counter value retrieval returned	{"error": "A counter with a negative value was detected.", "cstatus": "A counter with a negative value was detected.", "perfmon": {"query": "\\\\DESKTOP-RFOOE09\\Process(SearchFilterHost)\\% Processor Time"}}
	Line 273453: 2020-05-07T18:18:42.141+0200	DEBUG	[perfmon]	perfmon/data.go:51	Counter value retrieval returned	{"error": "The data is not valid.", "cstatus": "The returned data is not valid.", "perfmon": {"query": "\\\\DESKTOP-RFOOE09\\Process(backgroundTaskHost)\\IO Read Bytes/sec"}}
	Line 273454: 2020-05-07T18:18:42.159+0200	DEBUG	[perfmon]	perfmon/data.go:51	Counter value retrieval returned	{"error": "The data is not valid.", "cstatus": "The returned data is not valid.", "perfmon": {"query": "\\\\DESKTOP-RFOOE09\\Process(backgroundTaskHost)\\IO Write Operations/sec"}}

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 7, 2020
@narph narph self-assigned this May 7, 2020
@narph narph added [zube]: In Review Metricbeat Metricbeat Team:Integrations Label for the Integrations team labels May 7, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@narph narph removed the needs_team Indicates that the issue/PR needs a Team:* label label May 7, 2020
@zube zube bot added [zube]: Inbox needs_team Indicates that the issue/PR needs a Team:* label [zube]: In Review and removed [zube]: In Review [zube]: Inbox needs_team Indicates that the issue/PR needs a Team:* label labels May 7, 2020
@zube zube bot added needs_team Indicates that the issue/PR needs a Team:* label [zube]: In Review [zube]: Inbox and removed [zube]: Inbox needs_team Indicates that the issue/PR needs a Team:* label [zube]: In Review labels May 7, 2020
@narph narph added [zube]: In Review and removed [zube]: Inbox needs_team Indicates that the issue/PR needs a Team:* label labels May 7, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented May 7, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

Test stats 🧪

Test Results
Failed 0
Passed 3022
Skipped 756
Total 3778

Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Left only some minor comments.

metricbeat/module/windows/perfmon/data.go Outdated Show resolved Hide resolved
@narph narph requested a review from ChrsMark May 12, 2020 10:45
@narph narph merged commit 89a4f3a into elastic:master May 12, 2020
@narph narph deleted the handle-perfmon branch May 12, 2020 12:02
narph added a commit to narph/beats that referenced this pull request May 12, 2020
…lastic#18361)

* handle errors

* update changelog

* fix tests

* address review

(cherry picked from commit 89a4f3a)
narph added a commit to narph/beats that referenced this pull request May 12, 2020
…lastic#18361)

* handle errors

* update changelog

* fix tests

* address review

(cherry picked from commit 89a4f3a)
@narph narph added the v7.8.0 label May 12, 2020
narph added a commit that referenced this pull request May 13, 2020
…18361) (#18450)

* handle errors

* update changelog

* fix tests

* address review

(cherry picked from commit 89a4f3a)
narph added a commit that referenced this pull request May 13, 2020
…18361) (#18449)

* handle errors

* update changelog

* fix tests

* address review

(cherry picked from commit 89a4f3a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metricbeat Metricbeat Team:Integrations Label for the Integrations team v7.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

windows/perfmon metricset - handle win32 api errors in the events
4 participants