Skip to content

Commit

Permalink
[x-pack][metricbeat][iis] improve error handling on pdh counters in a…
Browse files Browse the repository at this point in the history
…pplication_pool data stream
  • Loading branch information
stefans-elastic committed Jan 9, 2025
1 parent 04f1c4a commit 827bdeb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x-pack/metricbeat/module/iis/application_pool/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"strings"
"syscall"

"github.com/elastic/beats/v7/metricbeat/helper/windows/pdh"
"github.com/elastic/elastic-agent-libs/mapstr"
Expand Down Expand Up @@ -116,7 +117,7 @@ func (r *Reader) initAppPools() error {
for key, value := range appPoolCounters {
childQueries, err := r.query.GetCounterPaths(value)
if err != nil {
if errors.Is(err, pdh.PDH_CSTATUS_NO_COUNTER) || errors.Is(err, pdh.PDH_CSTATUS_NO_COUNTERNAME) || errors.Is(err, pdh.PDH_CSTATUS_NO_INSTANCE) || errors.Is(err, pdh.PDH_CSTATUS_NO_OBJECT) {
if err == pdh.PdhErrno(syscall.ERROR_NOT_FOUND) || errors.Is(err, pdh.PDH_CSTATUS_NO_COUNTER) || errors.Is(err, pdh.PDH_CSTATUS_NO_COUNTERNAME) || errors.Is(err, pdh.PDH_CSTATUS_NO_INSTANCE) || errors.Is(err, pdh.PDH_CSTATUS_NO_OBJECT) {

Check failure on line 120 in x-pack/metricbeat/module/iis/application_pool/reader.go

View workflow job for this annotation

GitHub Actions / lint (windows)

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
r.log.Infow("Ignoring non existent counter", "error", err,
logp.Namespace("application pool"), "query", value)
} else {
Expand Down

0 comments on commit 827bdeb

Please sign in to comment.