Skip to content

Commit

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

* Update changelog

* Fix changelog entry
  • Loading branch information
narph authored Oct 16, 2019
1 parent 9c6ea66 commit dbcb458
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 @@ -221,6 +221,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix rds metricset dashboard. {pull}13721[13721]
- Ignore prometheus untyped metrics with NaN value. {issue}13750[13750] {pull}13790[13790]
- Change kubernetes.event.message to text {pull}13964[13964]
- Fix performance counter values for windows/perfmon metricset.{issue}14036[14036] {pull}14039[14039]

*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 dbcb458

Please sign in to comment.