Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@
type: float
description: >
Current Queue Length.
- name: "state"
type: long
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) error {
return fmt.Errorf("failed reading counters: %w", err)
}

m.Logger().Infof("post_events: %+v", events)

for _, event := range events {
isOpen := report.Event(event)
if !isOpen {
Expand Down
19 changes: 16 additions & 3 deletions x-pack/metricbeat/module/iis/application_pool/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
// .NET CLR LocksAndThreads
"net_clr.locks_and_threads.contention_rate_per_sec": "\\.NET CLR LocksAndThreads(w3wp*)\\Contention Rate / sec",
"net_clr.locks_and_threads.current_queue_length": "\\.NET CLR LocksAndThreads(w3wp*)\\Current Queue Length",

"state": "\\APP_POOL_WAS(*)\\Current Application Pool State",
}

// newReader creates a new instance of Reader.
Expand Down Expand Up @@ -145,16 +147,26 @@
continue
}
for _, v := range childQueries {
if err := r.query.AddCounter(v, "", "float", len(childQueries) > 1); err != nil {
return fmt.Errorf(`failed to add counter (query="%v"): %w`, v, err)
if key == "test_state.state" {
if err := r.query.AddCounter(v, "", "long", len(childQueries) > 1); err != nil {
r.log.Infof("FAILED_COUNTER: %+v", err)
return fmt.Errorf(`failed to add counter (query="%v"): %w`, v, err)
}
r.log.Infof("ADDED_COUNTER: %+v", r.query.Counters)
} else {
if err := r.query.AddCounter(v, "", "float", len(childQueries) > 1); err != nil {
return fmt.Errorf(`failed to add counter (query="%v"): %w`, v, err)
}
}

r.workerProcesses[v] = key
}
}
err = r.query.RemoveUnusedCounters(newQueries)
if err != nil {
return fmt.Errorf("failed removing unused counter values: %w", err)
}

return nil
}

Expand Down Expand Up @@ -197,6 +209,7 @@
},
RootFields: mapstr.M{},
}

for counterPath, value := range values {
for _, val := range value {
// Some counters, such as rate counters, require two counter values in order to compute a displayable value. In this case we must call PdhCollectQueryData twice before calling PdhGetFormattedCounterValue.
Expand All @@ -214,7 +227,7 @@
continue
}
}
if hasWorkerProcess(val.Instance, workers, appPool.workerProcessIds) {
if hasWorkerProcess(val.Instance, workers, appPool.workerProcessIds) || val.Instance == appPool.name {
if r.workerProcesses[counterPath] == ecsProcessId {
events[appPool.name].RootFields.Put(r.workerProcesses[counterPath], val.Measurement)
} else if len(r.workerProcesses[counterPath]) != 0 {
Expand Down Expand Up @@ -293,7 +306,7 @@
var workers []WorkerProcess
for key, values := range counterValues {
if strings.Contains(key, "\\ID Process") && values[0].Measurement != nil {
workers = append(workers, WorkerProcess{instanceName: values[0].Instance, processId: int(values[0].Measurement.(float64))})

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

View workflow job for this annotation

GitHub Actions / lint (windows-latest)

Error return value is not checked (errcheck)
}
}
return workers
Expand Down
Loading