[8.17](backport #42274) [x-pack][metricbeat][iis] improve error handling on pdh counters in application_pool data stream #42335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
The error occurs initAppPools > calls GetCounterPaths > calls ExpandWildCardPath > calls PdhExpandWildCardPath which returns no data and no error >
PdhExpandWildCardPath
returnsPdhErrno(syscall.ERROR_NOT_FOUND)
error here > the error returns all the way back toinitAppPools
and since the error type isn't part of this condition an error log appears (logged here).On why PDH's function returns no data and no error - I didn't find a coverage of this behavior in the docs. My guess is that object/counter exists but has no data in it (for w3wp process).
The fix I suggest is simply adding a check for
PdhErrno(syscall.ERROR_NOT_FOUND)
error in this condition which prevents those errors causing unnecessary error level log entries.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Screenshots
Before the change (
Element not found.failed to expand counter path
errors show up in the logs)After the change (NO
Element not found.failed to expand counter path
errors show up in the logs)This is an automatic backport of pull request #42274 done by [Mergify](https://mergify.com).