From d0a570cf5a85d897e1a0f2e445c8a37273f6f2e9 Mon Sep 17 00:00:00 2001 From: Mariana Dima Date: Thu, 5 Mar 2020 10:36:16 +0100 Subject: [PATCH] Cherry-pick #14271 to 7.x: Convert ticks to milliseconds for diskio metricset (#16797) * Convert ticks to milliseconds for diskio (#14271) (cherry picked from commit 88927660af22862c18a8d24340b9c9fb69ce9667) * changelog * remove space --- CHANGELOG.next.asciidoc | 1 + .../system/diskio/diskstat_windows_helper.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index ea678d1bd8a..5c87eeb648e 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -150,6 +150,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Revert changes in `docker` module: add size flag to docker.container. {pull}16600[16600] - Fix detection and logging of some error cases with light modules. {pull}14706[14706] - Add dashboard for `redisenterprise` module. {pull}16752[16752] +- Convert increments of 100 nanoseconds/ticks to milliseconds for WriteTime and ReadTime in diskio metricset (Windows) for consistency. {issue}14233[14233] *Packetbeat* diff --git a/metricbeat/module/system/diskio/diskstat_windows_helper.go b/metricbeat/module/system/diskio/diskstat_windows_helper.go index 0e550a71f45..8f218b81b8c 100644 --- a/metricbeat/module/system/diskio/diskstat_windows_helper.go +++ b/metricbeat/module/system/diskio/diskstat_windows_helper.go @@ -50,10 +50,13 @@ type logicalDrive struct { } type diskPerformance struct { - BytesRead int64 - BytesWritten int64 - ReadTime int64 - WriteTime int64 + BytesRead int64 + BytesWritten int64 + // Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks). + ReadTime int64 + // Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks). + WriteTime int64 + //Contains a cumulative time, expressed in increments of 100 nanoseconds (or ticks). IdleTime int64 ReadCount uint32 WriteCount uint32 @@ -95,8 +98,9 @@ func ioCounters(names ...string) (map[string]disk.IOCountersStat, error) { WriteCount: uint64(counter.WriteCount), ReadBytes: uint64(counter.BytesRead), WriteBytes: uint64(counter.BytesWritten), - ReadTime: uint64(counter.ReadTime), - WriteTime: uint64(counter.WriteTime), + // Ticks (which is equal to 100 nanoseconds) will be converted to milliseconds for consistency reasons for both ReadTime and WriteTime (https://docs.microsoft.com/en-us/dotnet/api/system.timespan.ticks?redirectedfrom=MSDN&view=netframework-4.8#remarks) + ReadTime: uint64(counter.ReadTime / 10000), + WriteTime: uint64(counter.WriteTime / 10000), } } return ret, nil