mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-07 21:46:37 +00:00
Rewrite cache collector to use perflib
Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
@@ -1,103 +1,104 @@
|
|||||||
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/StackExchange/wmi"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/common/log"
|
"github.com/prometheus/common/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Factories["cache"] = NewCacheCollector
|
registerCollector("cache", newCacheCollector, "Cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
// A CacheCollector is a Prometheus collector for WMI Win32_PerfFormattedData_PerfOS_Cache metrics
|
// A CacheCollector is a Prometheus collector for Perflib Cache metrics
|
||||||
type CacheCollector struct {
|
type CacheCollector struct {
|
||||||
AsyncCopyReadsPersec *prometheus.Desc
|
AsyncCopyReadsTotal *prometheus.Desc
|
||||||
AsyncDataMapsPersec *prometheus.Desc
|
AsyncDataMapsTotal *prometheus.Desc
|
||||||
AsyncFastReadsPersec *prometheus.Desc
|
AsyncFastReadsTotal *prometheus.Desc
|
||||||
AsyncMDLReadsPersec *prometheus.Desc
|
AsyncMDLReadsTotal *prometheus.Desc
|
||||||
AsyncPinReadsPersec *prometheus.Desc
|
AsyncPinReadsTotal *prometheus.Desc
|
||||||
CopyReadHitsPercent *prometheus.Desc
|
CopyReadHitsTotal *prometheus.Desc
|
||||||
CopyReadsPersec *prometheus.Desc
|
CopyReadsTotal *prometheus.Desc
|
||||||
DataFlushesPersec *prometheus.Desc
|
DataFlushesTotal *prometheus.Desc
|
||||||
DataFlushPagesPersec *prometheus.Desc
|
DataFlushPagesTotal *prometheus.Desc
|
||||||
DataMapHitsPercent *prometheus.Desc
|
DataMapHitsPercent *prometheus.Desc
|
||||||
DataMapPinsPersec *prometheus.Desc
|
DataMapPinsTotal *prometheus.Desc
|
||||||
DataMapsPersec *prometheus.Desc
|
DataMapsTotal *prometheus.Desc
|
||||||
DirtyPages *prometheus.Desc
|
DirtyPages *prometheus.Desc
|
||||||
DirtyPageThreshold *prometheus.Desc
|
DirtyPageThreshold *prometheus.Desc
|
||||||
FastReadNotPossiblesPersec *prometheus.Desc
|
FastReadNotPossiblesTotal *prometheus.Desc
|
||||||
FastReadResourceMissesPersec *prometheus.Desc
|
FastReadResourceMissesTotal *prometheus.Desc
|
||||||
FastReadsPersec *prometheus.Desc
|
FastReadsTotal *prometheus.Desc
|
||||||
LazyWriteFlushesPersec *prometheus.Desc
|
LazyWriteFlushesTotal *prometheus.Desc
|
||||||
LazyWritePagesPersec *prometheus.Desc
|
LazyWritePagesTotal *prometheus.Desc
|
||||||
MDLReadHitsPercent *prometheus.Desc
|
MDLReadHitsTotal *prometheus.Desc
|
||||||
MDLReadsPersec *prometheus.Desc
|
MDLReadsTotal *prometheus.Desc
|
||||||
PinReadHitsPercent *prometheus.Desc
|
PinReadHitsTotal *prometheus.Desc
|
||||||
PinReadsPersec *prometheus.Desc
|
PinReadsTotal *prometheus.Desc
|
||||||
ReadAheadsPersec *prometheus.Desc
|
ReadAheadsTotal *prometheus.Desc
|
||||||
SyncCopyReadsPersec *prometheus.Desc
|
SyncCopyReadsTotal *prometheus.Desc
|
||||||
SyncDataMapsPersec *prometheus.Desc
|
SyncDataMapsTotal *prometheus.Desc
|
||||||
SyncFastReadsPersec *prometheus.Desc
|
SyncFastReadsTotal *prometheus.Desc
|
||||||
SyncMDLReadsPersec *prometheus.Desc
|
SyncMDLReadsTotal *prometheus.Desc
|
||||||
SyncPinReadsPersec *prometheus.Desc
|
SyncPinReadsTotal *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCacheCollector ...
|
// NewCacheCollector ...
|
||||||
func NewCacheCollector() (Collector, error) {
|
func newCacheCollector() (Collector, error) {
|
||||||
const subsystem = "cache"
|
const subsystem = "cache"
|
||||||
return &CacheCollector{
|
return &CacheCollector{
|
||||||
AsyncCopyReadsPersec: prometheus.NewDesc(
|
AsyncCopyReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "async_copy_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "async_copy_reads_total"),
|
||||||
"(AsyncCopyReadsPersec)",
|
"(AsyncCopyReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
AsyncDataMapsPersec: prometheus.NewDesc(
|
AsyncDataMapsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "async_data_maps_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "async_data_maps_total"),
|
||||||
"(AsyncDataMapsPersec)",
|
"(AsyncDataMapsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
AsyncFastReadsPersec: prometheus.NewDesc(
|
AsyncFastReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "async_fast_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "async_fast_reads_total"),
|
||||||
"(AsyncFastReadsPersec)",
|
"(AsyncFastReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
AsyncMDLReadsPersec: prometheus.NewDesc(
|
AsyncMDLReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "async_mdl_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "async_mdl_reads_total"),
|
||||||
"(AsyncMDLReadsPersec)",
|
"(AsyncMDLReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
AsyncPinReadsPersec: prometheus.NewDesc(
|
AsyncPinReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "async_pin_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "async_pin_reads_total"),
|
||||||
"(AsyncPinReadsPersec)",
|
"(AsyncPinReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
CopyReadHitsPercent: prometheus.NewDesc(
|
CopyReadHitsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "copy_read_hits_percent"),
|
prometheus.BuildFQName(Namespace, subsystem, "copy_read_hits_total"),
|
||||||
"(CopyReadHitsPercent)",
|
"(CopyReadHitsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
CopyReadsPersec: prometheus.NewDesc(
|
CopyReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "copy_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "copy_reads_total"),
|
||||||
"(CopyReadsPersec)",
|
"(CopyReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
DataFlushesPersec: prometheus.NewDesc(
|
DataFlushesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "data_flushes_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "data_flushes_total"),
|
||||||
"(DataFlushesPersec)",
|
"(DataFlushesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
DataFlushPagesPersec: prometheus.NewDesc(
|
DataFlushPagesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "data_flush_pages_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "data_flush_pages_total"),
|
||||||
"(DataFlushPagesPersec)",
|
"(DataFlushPagesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
@@ -107,15 +108,15 @@ func NewCacheCollector() (Collector, error) {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
DataMapPinsPersec: prometheus.NewDesc(
|
DataMapPinsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "data_map_pins_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "data_map_pins_total"),
|
||||||
"(DataMapPinsPersec)",
|
"(DataMapPinsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
DataMapsPersec: prometheus.NewDesc(
|
DataMapsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "data_maps_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "data_maps_total"),
|
||||||
"(DataMapsPersec)",
|
"(DataMapsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
@@ -131,322 +132,320 @@ func NewCacheCollector() (Collector, error) {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
FastReadNotPossiblesPersec: prometheus.NewDesc(
|
FastReadNotPossiblesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "fast_read_not_possibles_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "fast_read_not_possibles_total"),
|
||||||
"(FastReadNotPossiblesPersec)",
|
"(FastReadNotPossiblesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
FastReadResourceMissesPersec: prometheus.NewDesc(
|
FastReadResourceMissesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "fast_read_resource_misses_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "fast_read_resource_misses_total"),
|
||||||
"(FastReadResourceMissesPersec)",
|
"(FastReadResourceMissesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
FastReadsPersec: prometheus.NewDesc(
|
FastReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "fast_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "fast_reads_total"),
|
||||||
"(FastReadsPersec)",
|
"(FastReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
LazyWriteFlushesPersec: prometheus.NewDesc(
|
LazyWriteFlushesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "lazy_write_flushes_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "lazy_write_flushes_total"),
|
||||||
"(LazyWriteFlushesPersec)",
|
"(LazyWriteFlushesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
LazyWritePagesPersec: prometheus.NewDesc(
|
LazyWritePagesTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "lazy_write_pages_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "lazy_write_pages_total"),
|
||||||
"(LazyWritePagesPersec)",
|
"(LazyWritePagesTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
MDLReadHitsPercent: prometheus.NewDesc(
|
MDLReadHitsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "mdl_read_hits_percent"),
|
prometheus.BuildFQName(Namespace, subsystem, "mdl_read_hits_total"),
|
||||||
"(MDLReadHitsPercent)",
|
"(MDLReadHitsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
MDLReadsPersec: prometheus.NewDesc(
|
MDLReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "mdl_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "mdl_reads_total"),
|
||||||
"(MDLReadsPersec)",
|
"(MDLReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
PinReadHitsPercent: prometheus.NewDesc(
|
PinReadHitsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "pin_read_hits_percent"),
|
prometheus.BuildFQName(Namespace, subsystem, "pin_read_hits_total"),
|
||||||
"(PinReadHitsPercent)",
|
"(PinReadHitsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
PinReadsPersec: prometheus.NewDesc(
|
PinReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "pin_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "pin_reads_total"),
|
||||||
"(PinReadsPersec)",
|
"(PinReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
ReadAheadsPersec: prometheus.NewDesc(
|
ReadAheadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "read_aheads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "read_aheads_total"),
|
||||||
"(ReadAheadsPersec)",
|
"(ReadAheadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
SyncCopyReadsPersec: prometheus.NewDesc(
|
SyncCopyReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "sync_copy_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "sync_copy_reads_total"),
|
||||||
"(SyncCopyReadsPersec)",
|
"(SyncCopyReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
SyncDataMapsPersec: prometheus.NewDesc(
|
SyncDataMapsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "sync_data_maps_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "sync_data_maps_total"),
|
||||||
"(SyncDataMapsPersec)",
|
"(SyncDataMapsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
SyncFastReadsPersec: prometheus.NewDesc(
|
SyncFastReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "sync_fast_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "sync_fast_reads_total"),
|
||||||
"(SyncFastReadsPersec)",
|
"(SyncFastReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
SyncMDLReadsPersec: prometheus.NewDesc(
|
SyncMDLReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "sync_mdl_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "sync_mdl_reads_total"),
|
||||||
"(SyncMDLReadsPersec)",
|
"(SyncMDLReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
SyncPinReadsPersec: prometheus.NewDesc(
|
SyncPinReadsTotal: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "sync_pin_reads_persec"),
|
prometheus.BuildFQName(Namespace, subsystem, "sync_pin_reads_total"),
|
||||||
"(SyncPinReadsPersec)",
|
"(SyncPinReadsTotal)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect sends the metric values for each metric
|
// Collect implements the Collector interface
|
||||||
// to the provided prometheus Metric channel.
|
|
||||||
func (c *CacheCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
func (c *CacheCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||||
if desc, err := c.collect(ch); err != nil {
|
if desc, err := c.collect(ctx, ch); err != nil {
|
||||||
log.Error("failed collecting cache metrics:", desc, err)
|
log.Error("failed collecting cache metrics:", desc, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Win32_PerfFormattedData_PerfOS_Cache docs:
|
// Perflib "Cache":
|
||||||
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
|
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
|
||||||
type Win32_PerfFormattedData_PerfOS_Cache struct {
|
type perflibCache struct {
|
||||||
AsyncCopyReadsPersec uint32
|
AsyncCopyReadsTotal float64 `perflib:"Async Copy Reads/sec"`
|
||||||
AsyncDataMapsPersec uint32
|
AsyncDataMapsTotal float64 `perflib:"Async Data Maps/sec"`
|
||||||
AsyncFastReadsPersec uint32
|
AsyncFastReadsTotal float64 `perflib:"Async Fast Reads/sec"`
|
||||||
AsyncMDLReadsPersec uint32
|
AsyncMDLReadsTotal float64 `perflib:"Async MDL Reads/sec"`
|
||||||
AsyncPinReadsPersec uint32
|
AsyncPinReadsTotal float64 `perflib:"Async Pin Reads/sec"`
|
||||||
CopyReadHitsPercent uint32
|
CopyReadHitsTotal float64 `perflib:"Copy Read Hits %"`
|
||||||
CopyReadsPersec uint32
|
CopyReadsTotal float64 `perflib:"Copy Reads/sec"`
|
||||||
DataFlushesPersec uint32
|
DataFlushesTotal float64 `perflib:"Data Flushes/sec"`
|
||||||
DataFlushPagesPersec uint32
|
DataFlushPagesTotal float64 `perflib:"Data Flush Pages/sec"`
|
||||||
DataMapHitsPercent uint32
|
DataMapHitsPercent float64 `perflib:"Data Map Hits %"`
|
||||||
DataMapPinsPersec uint32
|
DataMapPinsTotal float64 `perflib:"Data Map Pins/sec"`
|
||||||
DataMapsPersec uint32
|
DataMapsTotal float64 `perflib:"Data Maps/sec"`
|
||||||
DirtyPages uint64
|
DirtyPages float64 `perflib:"Dirty Pages"`
|
||||||
DirtyPageThreshold uint64
|
DirtyPageThreshold float64 `perflib:"Dirty Page Threshold"`
|
||||||
FastReadNotPossiblesPersec uint32
|
FastReadNotPossiblesTotal float64 `perflib:"Fast Read Not Possibles/sec"`
|
||||||
FastReadResourceMissesPersec uint32
|
FastReadResourceMissesTotal float64 `perflib:"Fast Read Resource Misses/sec"`
|
||||||
FastReadsPersec uint32
|
FastReadsTotal float64 `perflib:"Fast Reads/sec"`
|
||||||
LazyWriteFlushesPersec uint32
|
LazyWriteFlushesTotal float64 `perflib:"Lazy Write Flushes/sec"`
|
||||||
LazyWritePagesPersec uint32
|
LazyWritePagesTotal float64 `perflib:"Lazy Write Pages/sec"`
|
||||||
MDLReadHitsPercent uint32
|
MDLReadHitsTotal float64 `perflib:"MDL Read Hits %"`
|
||||||
MDLReadsPersec uint32
|
MDLReadsTotal float64 `perflib:"MDL Reads/sec"`
|
||||||
PinReadHitsPercent uint32
|
PinReadHitsTotal float64 `perflib:"Pin Read Hits %"`
|
||||||
PinReadsPersec uint32
|
PinReadsTotal float64 `perflib:"Pin Reads/sec"`
|
||||||
ReadAheadsPersec uint32
|
ReadAheadsTotal float64 `perflib:"Read Aheads/sec"`
|
||||||
SyncCopyReadsPersec uint32
|
SyncCopyReadsTotal float64 `perflib:"Sync Copy Reads/sec"`
|
||||||
SyncDataMapsPersec uint32
|
SyncDataMapsTotal float64 `perflib:"Sync Data Maps/sec"`
|
||||||
SyncFastReadsPersec uint32
|
SyncFastReadsTotal float64 `perflib:"Sync Fast Reads/sec"`
|
||||||
SyncMDLReadsPersec uint32
|
SyncMDLReadsTotal float64 `perflib:"Sync MDL Reads/sec"`
|
||||||
SyncPinReadsPersec uint32
|
SyncPinReadsTotal float64 `perflib:"Sync Pin Reads/sec"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CacheCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
func (c *CacheCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
||||||
var dst []Win32_PerfFormattedData_PerfOS_Cache
|
var dst []perflibCache // Single-instance class, array is required but will have single entry.
|
||||||
q := queryAll(&dst)
|
if err := unmarshalObject(ctx.perfObjects["Cache"], &dst); err != nil {
|
||||||
if err := wmi.Query(q, &dst); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.AsyncCopyReadsPersec,
|
c.AsyncCopyReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].AsyncCopyReadsPersec),
|
dst[0].AsyncCopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.AsyncDataMapsPersec,
|
c.AsyncDataMapsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].AsyncDataMapsPersec),
|
dst[0].AsyncDataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.AsyncFastReadsPersec,
|
c.AsyncFastReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].AsyncFastReadsPersec),
|
dst[0].AsyncFastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.AsyncMDLReadsPersec,
|
c.AsyncMDLReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].AsyncMDLReadsPersec),
|
dst[0].AsyncMDLReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.AsyncPinReadsPersec,
|
c.AsyncPinReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].AsyncPinReadsPersec),
|
dst[0].AsyncPinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.CopyReadHitsPercent,
|
c.CopyReadHitsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(dst[0].CopyReadHitsPercent),
|
dst[0].CopyReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.CopyReadsPersec,
|
c.CopyReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].CopyReadsPersec),
|
dst[0].CopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DataFlushesPersec,
|
c.DataFlushesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].DataFlushesPersec),
|
dst[0].DataFlushesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DataFlushPagesPersec,
|
c.DataFlushPagesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].DataFlushPagesPersec),
|
dst[0].DataFlushPagesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DataMapHitsPercent,
|
c.DataMapHitsPercent,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(dst[0].DataMapHitsPercent),
|
dst[0].DataMapHitsPercent,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DataMapPinsPersec,
|
c.DataMapPinsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].DataMapPinsPersec),
|
dst[0].DataMapPinsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DataMapsPersec,
|
c.DataMapsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].DataMapsPersec),
|
dst[0].DataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DirtyPages,
|
c.DirtyPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(dst[0].DirtyPages),
|
dst[0].DirtyPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.DirtyPageThreshold,
|
c.DirtyPageThreshold,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(dst[0].DirtyPageThreshold),
|
dst[0].DirtyPageThreshold,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.FastReadNotPossiblesPersec,
|
c.FastReadNotPossiblesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].FastReadNotPossiblesPersec),
|
dst[0].FastReadNotPossiblesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.FastReadResourceMissesPersec,
|
c.FastReadResourceMissesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].FastReadResourceMissesPersec),
|
dst[0].FastReadResourceMissesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.FastReadsPersec,
|
c.FastReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].FastReadsPersec),
|
dst[0].FastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.LazyWriteFlushesPersec,
|
c.LazyWriteFlushesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].LazyWriteFlushesPersec),
|
dst[0].LazyWriteFlushesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.LazyWritePagesPersec,
|
c.LazyWritePagesTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].LazyWritePagesPersec),
|
dst[0].LazyWritePagesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.MDLReadHitsPercent,
|
c.MDLReadHitsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].MDLReadHitsPercent),
|
dst[0].MDLReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.MDLReadsPersec,
|
c.MDLReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].MDLReadsPersec),
|
dst[0].MDLReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.PinReadHitsPercent,
|
c.PinReadHitsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].PinReadHitsPercent),
|
dst[0].PinReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.PinReadsPersec,
|
c.PinReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].PinReadsPersec),
|
dst[0].PinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ReadAheadsPersec,
|
c.ReadAheadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].ReadAheadsPersec),
|
dst[0].ReadAheadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.SyncCopyReadsPersec,
|
c.SyncCopyReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].SyncCopyReadsPersec),
|
dst[0].SyncCopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.SyncDataMapsPersec,
|
c.SyncDataMapsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].SyncDataMapsPersec),
|
dst[0].SyncDataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.SyncFastReadsPersec,
|
c.SyncFastReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].SyncFastReadsPersec),
|
dst[0].SyncFastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.SyncMDLReadsPersec,
|
c.SyncMDLReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].SyncMDLReadsPersec),
|
dst[0].SyncMDLReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.SyncPinReadsPersec,
|
c.SyncPinReadsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.CounterValue,
|
||||||
float64(dst[0].SyncPinReadsPersec),
|
dst[0].SyncPinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ The cache collector exposes metrics about file system cache
|
|||||||
|||
|
|||
|
||||||
-|-
|
-|-
|
||||||
Metric name prefix | `cache`
|
Metric name prefix | `cache`
|
||||||
|
Data Source | Perflib
|
||||||
Classes | [`Win32_PerfFormattedData_PerfOS_Cache`](https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85))
|
Classes | [`Win32_PerfFormattedData_PerfOS_Cache`](https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85))
|
||||||
Enabled by default? | No
|
Enabled by default? | No
|
||||||
|
|
||||||
@@ -16,38 +17,41 @@ None
|
|||||||
|
|
||||||
Name | Description | Type | Labels
|
Name | Description | Type | Labels
|
||||||
-----|-------------|------|-------
|
-----|-------------|------|-------
|
||||||
`wmi_cache_async_copy_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_async_copy_reads_total` | Number of times that a filesystem, such as NTFS, maps a page of a file into the file system cache to read a page. | counter | None
|
||||||
`wmi_cache_async_data_maps_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_async_data_maps_total` | Number of times that a filesystem, such as NTFS, maps a page of a file into the file system cache to read the page, and wishes to wait for the page to be retrieved if it is not in main memory. | counter | None
|
||||||
`wmi_cache_async_fast_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_async_fast_reads_total` | Number of reads from the file system cache that bypass the installed file system and retrieve the data directly from the cache. | counter | None
|
||||||
`wmi_cache_async_mdl_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_async_mdl_reads_total` | Number of reads from the file system cache that use a Memory Descriptor List (MDL) to access the pages. | counter | None
|
||||||
`wmi_cache_async_pin_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_async_pin_reads_total` | Number of reads from the file system cache preparatory to writing the data back to disk. Pages read in this fashion are pinned in memory at the completion of the read. | counter | None
|
||||||
`wmi_cache_copy_read_hits_percent` | _Not yet documented_ | gauge | None
|
`windows_cache_copy_read_hits_total` | Number of copy read requests that hit the cache, that is, they did not require a disk read in order to provide access to the page in the cache. | counter | None
|
||||||
`wmi_cache_copy_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_copy_reads_total` | Number of reads from pages of the file system cache that involve a memory copy of the data from the cache to the application's buffer. | counter | None
|
||||||
`wmi_cache_data_flushes_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_data_flushes_total` | Number of times the file system cache has flushed its contents to disk as the result of a request to flush or to satisfy a write-through file write request. | counter | None
|
||||||
`wmi_cache_data_flush_pages_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_data_flush_pages_total` | Number of pages the file system cache has flushed to disk as a result of a request to flush or to satisfy a write-through file write request. | counter | None
|
||||||
`wmi_cache_data_map_hits_percent` | _Not yet documented_ | gauge | None
|
`windows_cache_data_map_hits_total` | Number of data maps in the file system cache that could be resolved without having to retrieve a page from the disk, because the page was already in physical memory. | counter | None
|
||||||
`wmi_cache_data_map_pins_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_data_map_pins_total` | Number of data maps in the file system cache that resulted in pinning a page in main memory, an action usually preparatory to writing to the file on disk. | counter | None
|
||||||
`wmi_cache_data_maps_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_data_maps_total` | Number of times that a file system such as NTFS, maps a page of a file into the file system cache to read the page. | counter | None
|
||||||
`wmi_cache_dirty_pages` | _Not yet documented_ | counter | None
|
`windows_cache_dirty_pages` | Number of dirty pages on the system cache. | gauge | None
|
||||||
`wmi_cache_dirty_page_threshold` | _Not yet documented_ | counter | None
|
`windows_cache_dirty_page_threshold` | Threshold for number of dirty pages on system cache. | gauge | None
|
||||||
`wmi_cache_fast_read_not_possibles_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_fast_read_not_possibles_total` | Number of attempts by an Application Program Interface (API) function call to bypass the file system to get to data in the file system cache that could not be honored without invoking the file system. | counter | None
|
||||||
`wmi_cache_fast_read_resource_misses_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_fast_read_resource_misses_total` | Number of cache misses necessitated by the lack of available resources to satisfy the request. | counter | None
|
||||||
`wmi_cache_fast_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_fast_reads_total` | Number of reads from the file system cache that bypass the installed file system and retrieve the data directly from the cache. | counter | None
|
||||||
`wmi_cache_lazy_write_flushes_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_lazy_write_flushes_total` | Number of Lazy Write flushes the Lazy Writer thread has written to disk. Lazy Writing is the process of updating the disk after the page has been changed in memory, so that the application that changed the file does not have to wait for the disk write to be complete before proceeding. | counter | None
|
||||||
`wmi_cache_lazy_write_pages_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_lazy_write_pages_total` | Number of Lazy Write pages the Lazy Writer thread has written to disk. Lazy Writing is the process of updating the disk after the page has been changed in memory, so that the application that changed the file does not have to wait for the disk write to be complete before proceeding. | counter | None
|
||||||
`wmi_cache_mdl_read_hits_percent` | _Not yet documented_ | gauge | None
|
`windows_cache_mdl_read_hits_total` | Number of Memory Descriptor List (MDL) Read requests to the file system cache that hit the cache, i.e., did not require disk accesses in order to provide memory access to the page(s) in the cache. | counter | None
|
||||||
`wmi_cache_mdl_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_mdl_reads_total` | Number of reads from the file system cache that use a Memory Descriptor List (MDL) to access the data. | counter | None
|
||||||
`wmi_cache_pin_read_hits_percent` | _Not yet documented_ | gauge | None
|
`windows_cache_pin_read_hits_total` | Number of pin read requests that hit the file system cache, i.e., did not require a disk read in order to provide access to the page in the file system cache. While pinned, a page's physical address in the file system cache will not be altered. | counter | None
|
||||||
`wmi_cache_pin_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_pin_reads_total` | Number of reads into the file system cache preparatory to writing the data back to disk. Pages read in this fashion are pinned in memory at the completion of the read. While pinned, a page's physical address in the file system cache will not be altered. | counter | None
|
||||||
`wmi_cache_read_aheads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_read_aheads_total` | Number of reads from the file system cache in which the Cache detects sequential access to a file. The read aheads permit the data to be transferred in larger blocks than those being requested by the application, reducing the overhead per access. | counter | None
|
||||||
`wmi_cache_sync_copy_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_sync_copy_reads_total` | Number of reads from pages of the file system cache that involve a memory copy of the data from the cache to the application's buffer. The file system will not regain control until the copy operation is complete, even if the disk must be accessed to retrieve the page. | counter | None
|
||||||
`wmi_cache_sync_data_maps_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_sync_data_maps_total` | Number of times that a file system such as NTFS maps a page of a file into the file system cache to read the page. | counter | None
|
||||||
`wmi_cache_sync_fast_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_sync_fast_reads_total` | Number of reads from the file system cache that bypass the installed file system and retrieve the data directly from the cache. If the data is not in the cache, the request (application program call) will wait until the data has been retrieved from disk. | counter | None
|
||||||
`wmi_cache_sync_mdl_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_sync_mdl_reads_total` | Number of reads from the file system cache that use a Memory Descriptor List (MDL) to access the pages. If the accessed page(s) are not in main memory, the caller will wait for the pages to fault in from the disk. | counter | None
|
||||||
`wmi_cache_sync_pin_reads_persec` | _Not yet documented_ | gauge | None
|
`windows_cache_sync_pin_reads_total` | Number of reads into the file system cache preparatory to writing the data back to disk. The file system will not regain control until the page is pinned in the file system cache, in particular if the disk must be accessed to retrieve the page. | counter | None
|
||||||
|
|
||||||
### Example metric
|
### Example metric
|
||||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
Percentage of copy reads that hit the cache
|
||||||
|
```
|
||||||
|
windows_cache_copy_read_hits_total / windows_cache_copy_reads_total * 100
|
||||||
|
```
|
||||||
|
|
||||||
## Useful queries
|
## Useful queries
|
||||||
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
|
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
|
||||||
|
|||||||
Reference in New Issue
Block a user