Skip to content

Commit

Permalink
Fix performance counter values (elastic#14039) (elastic#14108)
Browse files Browse the repository at this point in the history
* Fix performance counter values  (elastic#14039)

* Fix counter values

* Update changelog

* Fix changelog entry

(cherry picked from commit dbcb458)

* Cleanup changelog
  • Loading branch information
narph authored Oct 17, 2019
1 parent e96c61e commit ff0d871
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Metricbeat*

- Fix performance counter values for windows/perfmon metricset.{issue}14036[14036] {pull}14039[14039] {pull}14108[14108]

*Packetbeat*

Expand Down
8 changes: 3 additions & 5 deletions metricbeat/module/windows/perfmon/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ func (r *Reader) RefreshCounterPaths() error {
if err != nil {
return errors.Wrap(err, "failed removing unused counter values")
}
// 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.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if err = r.query.CollectData(); err != nil {
return errors.Wrap(err, "failed querying counter values")
}

return nil
}

// Read executes a query and returns those values in an event.
func (r *Reader) Read() ([]mb.Event, error) {
// 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.
// For more information, see Collecting Performance Data (https://docs.microsoft.com/en-us/windows/desktop/PerfCtrs/collecting-performance-data).
if err := r.query.CollectData(); err != nil {
return nil, errors.Wrap(err, "failed querying counter values")
}
Expand Down

0 comments on commit ff0d871

Please sign in to comment.