-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix: don't fail merticbeat/windows/perfmon when no data is available #42803
base: main
Are you sure you want to change the base?
fix: don't fail merticbeat/windows/perfmon when no data is available #42803
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
This pull request is now in conflicts. Could you fix it? 🙏
|
re.log.Warnf("%s %v", collectFailedMsg, err) | ||
} else if err == pdh.PDH_NO_DATA { //nolint:errorlint // the same thing as above ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance I could convince you to turn this into a switch statement? Usually once you need an else if
a switch
ends up being a little cleaner.
re.log.Warnf("%s %v", collectFailedMsg, err) | ||
|
||
// without the return statement here it still fails when trying to get counter values | ||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like for PDH_NO_COUNTERS, we still try to get values, which would return error.
Why are we trying getvalues here for this case ?
IMO, we are doing the right thing by returning when PDH_NO_DATA is hit and not propagating the error to getvalues.
thoughts on this behaviour difference between the two error handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts on this behaviour difference between the two error handling?
I'm not sure. It is the reason I've implemented it this way (instead of doing something like if err == pdh.PDH_NO_COUNTERS || err == pdh.PDH_NO_DATA
) - I din't want to change original behavior since I'm not sure 'why' it was done this way. Although now that I'm thinking about this again I think it is a bug in original behavior and I probably should change to something like
if err == pdh.PDH_NO_COUNTERS || err == pdh.PDH_NO_DATA {
re.log.Warnf("%s %v", collectFailedMsg, err)
// without the return statement here it still fails when trying to get counter values
return nil, nil
}
WDYT?
@stefans-elastic : It would be good to add tests for the check |
Proposed commit message
The bug causes issue in iis/webserver module when IIS isn't installed (meaning there is no data to collect), it makes elastic-agent to go to DEGRATED state:

Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
Closes #42802
Use cases
Screenshots
Logs