diff --git a/x-pack/metricbeat/module/iis/application_pool/reader.go b/x-pack/metricbeat/module/iis/application_pool/reader.go index bdfef9b6683..59d9ddf253b 100644 --- a/x-pack/metricbeat/module/iis/application_pool/reader.go +++ b/x-pack/metricbeat/module/iis/application_pool/reader.go @@ -112,16 +112,24 @@ func (r *Reader) initAppPools() error { r.log.Info("no running application pools found") return nil } + isPDHError := func(err error) bool { + return errors.Is(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) + } var newQueries []string r.workerProcesses = make(map[string]string) for key, value := range appPoolCounters { childQueries, err := r.query.GetCounterPaths(value) if err != nil { - if errors.Is(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) { + if isPDHError(err) { r.log.Infow("Ignoring non existent counter", "error", err, - logp.Namespace("application pool"), "query", value) + logp.Namespace("application pool"), "query", value, + ) } else { - r.log.Error(err, `failed to expand counter path (query= "%v")`, value) + r.log.Errorf(`failed to expand counter path (query= "%v"): %w`, value, err) } continue }