Metrics for IO errors on Mac. (#1636)

* Metrics for IO errors and retries on Mac.

Signed-off-by: Tom Wilkie <tom@grafana.com>
This commit is contained in:
Tom Wilkie 2020-03-22 01:35:38 +05:30 committed by GitHub
parent 48bb6f670c
commit 6496c24d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 80 additions and 4 deletions

View File

@ -3,6 +3,7 @@
* [CHANGE]
* [FEATURE]
* [ENHANCEMENT] Add model_name and stepping to node_cpu_info metric #1617
* [ENHANCEMENT] Add metrics for IO errors and retires on Darwin. #1636
* [BUGFIX]
## 1.0.0-rc.0 / 2020-02-20

View File

@ -125,6 +125,62 @@ func NewDiskstatsCollector(logger log.Logger) (Collector, error) {
return float64(stat.BytesWritten)
},
},
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, "read_errors_total"),
"The total number of read errors.",
diskLabelNames,
nil,
),
valueType: prometheus.CounterValue,
},
value: func(stat *iostat.DriveStats) float64 {
return float64(stat.ReadErrors)
},
},
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, "write_errors_total"),
"The total number of write errors.",
diskLabelNames,
nil,
),
valueType: prometheus.CounterValue,
},
value: func(stat *iostat.DriveStats) float64 {
return float64(stat.WriteErrors)
},
},
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, "read_retries_total"),
"The total number of read retries.",
diskLabelNames,
nil,
),
valueType: prometheus.CounterValue,
},
value: func(stat *iostat.DriveStats) float64 {
return float64(stat.ReadRetries)
},
},
{
typedDesc: typedDesc{
desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, "write_retries_total"),
"The total number of write retries.",
diskLabelNames,
nil,
),
valueType: prometheus.CounterValue,
},
value: func(stat *iostat.DriveStats) float64 {
return float64(stat.WriteRetries)
},
},
},
logger: logger,
}, nil

2
go.mod
View File

@ -9,7 +9,7 @@ require (
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968
github.com/golang/protobuf v1.3.3 // indirect
github.com/hodgesds/perf-utils v0.0.8
github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3
github.com/lufia/iostat v1.1.0
github.com/mattn/go-xmlrpc v0.0.3
github.com/mdlayher/genetlink v1.0.0 // indirect
github.com/mdlayher/netlink v1.1.0 // indirect

4
go.sum
View File

@ -174,8 +174,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3 h1:XGhvld9vIpj929Gri5ybjukYZeyZwKkFkqgATqBQiOs=
github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3/go.mod h1:lRgtFVamD7L7GaXOSwBiuXMwU3Aicfn5h66LVs4u2SA=
github.com/lufia/iostat v1.1.0 h1:Z1wa4Hhxwi8uSKfgRsFc5RLtt3SuFPIOgkiPGkUtHDY=
github.com/lufia/iostat v1.1.0/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=

3
vendor/github.com/lufia/iostat/go.mod generated vendored Normal file
View File

@ -0,0 +1,3 @@
module github.com/lufia/iostat
go 1.14

View File

@ -17,6 +17,10 @@ type DriveStats struct {
TotalWriteTime time.Duration
ReadLatency time.Duration
WriteLatency time.Duration
ReadErrors int64
WriteErrors int64
ReadRetries int64
WriteRetries int64
}
// CPUStats represents CPU statistics.

View File

@ -95,6 +95,10 @@ static struct {
{kIOBlockStorageDriverStatisticsTotalWriteTimeKey, offsetof(DriveStats, writetime)},
{kIOBlockStorageDriverStatisticsLatentReadTimeKey, offsetof(DriveStats, readlat)},
{kIOBlockStorageDriverStatisticsLatentWriteTimeKey, offsetof(DriveStats, writelat)},
{kIOBlockStorageDriverStatisticsReadErrorsKey, offsetof(DriveStats, readerrs)},
{kIOBlockStorageDriverStatisticsWriteErrorsKey, offsetof(DriveStats, writeerrs)},
{kIOBlockStorageDriverStatisticsReadRetriesKey, offsetof(DriveStats, readretries)},
{kIOBlockStorageDriverStatisticsWriteRetriesKey, offsetof(DriveStats, writeretries)},
};
static int

View File

@ -32,6 +32,10 @@ func ReadDriveStats() ([]*DriveStats, error) {
TotalWriteTime: time.Duration(buf[i].writetime),
ReadLatency: time.Duration(buf[i].readlat),
WriteLatency: time.Duration(buf[i].writelat),
ReadErrors: int64(buf[i].readerrs),
WriteErrors: int64(buf[i].writeerrs),
ReadRetries: int64(buf[i].readretries),
WriteRetries: int64(buf[i].writeretries),
}
}
return stats, nil

View File

@ -19,6 +19,10 @@ struct DriveStats {
int64_t writetime;
int64_t readlat;
int64_t writelat;
int64_t readerrs;
int64_t writeerrs;
int64_t readretries;
int64_t writeretries;
};
struct CPUStats {

2
vendor/modules.txt vendored
View File

@ -30,7 +30,7 @@ github.com/golang/protobuf/ptypes/duration
github.com/golang/protobuf/ptypes/timestamp
# github.com/hodgesds/perf-utils v0.0.8
github.com/hodgesds/perf-utils
# github.com/lufia/iostat v0.0.0-20170605150913-9f7362b77ad3
# github.com/lufia/iostat v1.1.0
github.com/lufia/iostat
# github.com/mattn/go-xmlrpc v0.0.3
github.com/mattn/go-xmlrpc