Compare commits

...

27 Commits

Author SHA1 Message Date
Calle Pettersson
012b938b54 Merge pull request #402 from breed808/perf_mem
Use perflib for memory collector
2019-10-09 21:16:46 +02:00
Calle Pettersson
a0e5baa171 Merge pull request #403 from breed808/perf_net
Use perflib for net collector
2019-10-09 21:15:55 +02:00
Calle Pettersson
7611e33bc7 Merge pull request #405 from breed808/perf_system
Use perflib for system collector
2019-10-09 21:15:06 +02:00
Ben Reedy
2aafa9ebf3 Use perflib for system collector 2019-10-08 20:59:50 +10:00
Ben Reedy
f9f27b0b97 Use perflib for net collector 2019-10-08 20:57:09 +10:00
Ben Reedy
18128f48f5 Use perflib for memory collector 2019-10-08 20:52:44 +10:00
Calle Pettersson
2688847c2e Merge pull request #401 from breed808/adfs_loop
ADFS: explicitly use first perflib result
2019-10-07 17:47:51 +02:00
Calle Pettersson
1c605adb5e Merge pull request #400 from breed808/perf
Use Perflib for logical_disk exporter
2019-10-07 17:47:05 +02:00
Ben Reedy
d0877d0dc0 Update logical_disk docs to Perflib counter 2019-10-04 21:05:17 +10:00
Ben Reedy
2cd630fb2f Use ticks to seconds scale for latency metrics
Latency metrics were previously exposing as ticks
2019-10-04 21:05:17 +10:00
Ben Reedy
b210986181 Use perflib for logical_disk collector 2019-10-04 21:05:17 +10:00
Calle Pettersson
abd5a53045 Merge pull request #406 from floptical/master
Another msiexec install example
2019-10-01 17:53:51 +02:00
Calle Pettersson
aa394d1d8e Merge pull request #411 from breed808/established_gauge
Set tcp_connections_established to gauge type
2019-10-01 17:53:13 +02:00
Calle Pettersson
bdcc7b0913 Merge pull request #412 from Schlump/patch-1
Update collector.hyperv.md
2019-10-01 17:52:17 +02:00
Schlump
d7a908e6c0 Update collector.hyperv.md
Typo in metrics label.
Metrics exposed for Hyper-V collector are actually named "wmi_hyperv" and not "wmi_hyper".
2019-10-01 11:16:46 +02:00
Ben Reedy
c23a98ae90 Set tcp_connections_established to gauge type
While the ConnectionsEstablished property in the
Win32_PerfRawData_Tcpip_TCP class is listed as a counter, real-world
metric values have been shown to increase *and* decrease.

Documentation for the property states "Number of TCP connections for
which the *current* state is either ESTABLISHED or CLOSE-WAIT" which
would imply the metric is a gauge.
2019-09-27 19:48:16 +10:00
floptical
f8a7c99092 Another msiexec install example
msiexec install example for older windows versions
2019-09-25 15:48:36 -04:00
Ben Reedy
29b020999d Explicitly use first ADFS result
Perflib ADFS only returns a single data result, so looping over data is
unnecessary
2019-09-23 19:24:48 +10:00
Calle Pettersson
2f0a57898f Merge pull request #399 from breed808/adfs
Add adfs collector
2019-09-17 18:41:21 +02:00
Ben Reedy
1ad20d6eb8 Add adfs collector
Perflib is used to collect base AD FS performance counters.
A subset of the total performance counters has been added, but more will
likely be added in the future.

Documentation for the AD FS counters is poor. As such, some counters
have been omitted until their nature can be interpreted.
2019-09-17 21:45:53 +10:00
Calle Pettersson
de000b74c8 Merge pull request #396 from charlesmorin/patch-1
Added a required detail for the .prom file to work properly
2019-09-04 14:46:45 +02:00
Charles Morin
d860d92dc8 Added a required detail for the .prom file to work properly
After adding the `role.prom` file on Windows on around 15 virtual machines, we discovered that if omit to insert an empty line feed at the end of the file, Prometheus won't get metrics from the virtual machine. Adding a new line fixes the issue and immediately start gathering metrics for the virtual machine.
2019-09-04 08:44:26 -04:00
Calle Pettersson
3a19fe4e7d Merge pull request #393 from breed808/net_gauge
Set current_bandwidth to gauge type
2019-08-28 22:18:47 +02:00
Calle Pettersson
26a468f17a Merge pull request #392 from breed808/doc
Additional collector documentation
2019-08-28 22:18:17 +02:00
Ben Reedy
2c155a12bd Set current_bandwidth to gauge type
Bandwidth estimate for an interface may decrease or increase
2019-08-28 21:12:14 +10:00
Ben Reedy
e1141c3ec0 Add documentation for tcp collector 2019-08-28 21:06:23 +10:00
Ben Reedy
b635ecc6c1 Add documentation for os collector 2019-08-28 20:57:34 +10:00
17 changed files with 535 additions and 275 deletions

View File

@@ -10,6 +10,7 @@ Prometheus exporter for Windows machines, using the WMI (Windows Management Inst
Name | Description | Enabled by default Name | Description | Enabled by default
---------|-------------|-------------------- ---------|-------------|--------------------
[ad](docs/collector.ad.md) | Active Directory Domain Services | [ad](docs/collector.ad.md) | Active Directory Domain Services |
[adfs](docs/collector.adfs.md) | Active Directory Federation Services |
[cpu](docs/collector.cpu.md) | CPU usage | ✓ [cpu](docs/collector.cpu.md) | CPU usage | ✓
[cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) | ✓ [cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) | ✓
[container](docs/collector.container.md) | Container metrics | [container](docs/collector.container.md) | Container metrics |
@@ -68,6 +69,11 @@ Example service collector with a custom query.
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'""" msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'"""
``` ```
On some older versions of Windows you may need to surround parameter values with double quotes to get the install command parsing properly:
```powershell
msiexec /i C:\Users\Administrator\Downloads\wmi_exporter.msi ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,thermalzone" TEXTFILE_DIR="C:\custom_metrics\"
```
## Roadmap ## Roadmap
See [open issues](https://github.com/martinlindhe/wmi_exporter/issues) See [open issues](https://github.com/martinlindhe/wmi_exporter/issues)

188
collector/adfs.go Normal file
View File

@@ -0,0 +1,188 @@
// +build windows
package collector
import (
"github.com/prometheus/client_golang/prometheus"
)
func init() {
Factories["adfs"] = newADFSCollector
}
type adfsCollector struct {
adLoginConnectionFailures *prometheus.Desc
certificateAuthentications *prometheus.Desc
deviceAuthentications *prometheus.Desc
extranetAccountLockouts *prometheus.Desc
federatedAuthentications *prometheus.Desc
passportAuthentications *prometheus.Desc
passiveRequests *prometheus.Desc
passwordChangeFailed *prometheus.Desc
passwordChangeSucceeded *prometheus.Desc
tokenRequests *prometheus.Desc
windowsIntegratedAuthentications *prometheus.Desc
}
// newADFSCollector constructs a new adfsCollector
func newADFSCollector() (Collector, error) {
const subsystem = "adfs"
return &adfsCollector{
adLoginConnectionFailures: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "ad_login_connection_failures"),
"Total number of connection failures to an Active Directory domain controller",
nil,
nil,
),
certificateAuthentications: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "certificate_authentications"),
"Total number of User Certificate authentications",
nil,
nil,
),
deviceAuthentications: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "device_authentications"),
"Total number of Device authentications",
nil,
nil,
),
extranetAccountLockouts: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "extranet_account_lockouts"),
"Total number of Extranet Account Lockouts",
nil,
nil,
),
federatedAuthentications: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "federated_authentications"),
"Total number of authentications from a federated source",
nil,
nil,
),
passportAuthentications: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "passport_authentications"),
"Total number of Microsoft Passport SSO authentications",
nil,
nil,
),
passiveRequests: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "passive_requests"),
"Total number of passive (browser-based) requests",
nil,
nil,
),
passwordChangeFailed: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "password_change_failed"),
"Total number of failed password changes",
nil,
nil,
),
passwordChangeSucceeded: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "password_change_succeeded"),
"Total number of successful password changes",
nil,
nil,
),
tokenRequests: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "token_requests"),
"Total number of token requests",
nil,
nil,
),
windowsIntegratedAuthentications: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "windows_integrated_authentications"),
"Total number of Windows integrated authentications (Kerberos/NTLM)",
nil,
nil,
),
}, nil
}
type perflibADFS struct {
AdLoginConnectionFailures float64 `perflib:"AD login Connection Failures"`
CertificateAuthentications float64 `perflib:"Certificate Authentications"`
DeviceAuthentications float64 `perflib:"Device Authentications"`
ExtranetAccountLockouts float64 `perflib:"Extranet Account Lockouts"`
FederatedAuthentications float64 `perflib:"Federated Authentications"`
PassportAuthentications float64 `perflib:"Microsoft Passport Authentications"`
PassiveRequests float64 `perflib:"Passive Requests"`
PasswordChangeFailed float64 `perflib:"Password Change Failed Requests"`
PasswordChangeSucceeded float64 `perflib:"Password Change Successful Requests"`
TokenRequests float64 `perflib:"Token Requests"`
WindowsIntegratedAuthentications float64 `perflib:"Windows Integrated Authentications"`
}
func (c *adfsCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
var adfsData []perflibADFS
err := unmarshalObject(ctx.perfObjects["AD FS"], &adfsData)
if err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(
c.adLoginConnectionFailures,
prometheus.CounterValue,
adfsData[0].AdLoginConnectionFailures,
)
ch <- prometheus.MustNewConstMetric(
c.certificateAuthentications,
prometheus.CounterValue,
adfsData[0].CertificateAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.deviceAuthentications,
prometheus.CounterValue,
adfsData[0].DeviceAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.extranetAccountLockouts,
prometheus.CounterValue,
adfsData[0].ExtranetAccountLockouts,
)
ch <- prometheus.MustNewConstMetric(
c.federatedAuthentications,
prometheus.CounterValue,
adfsData[0].FederatedAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.passportAuthentications,
prometheus.CounterValue,
adfsData[0].PassportAuthentications,
)
ch <- prometheus.MustNewConstMetric(
c.passiveRequests,
prometheus.CounterValue,
adfsData[0].PassiveRequests,
)
ch <- prometheus.MustNewConstMetric(
c.passwordChangeFailed,
prometheus.CounterValue,
adfsData[0].PasswordChangeFailed,
)
ch <- prometheus.MustNewConstMetric(
c.passwordChangeSucceeded,
prometheus.CounterValue,
adfsData[0].PasswordChangeSucceeded,
)
ch <- prometheus.MustNewConstMetric(
c.tokenRequests,
prometheus.CounterValue,
adfsData[0].TokenRequests,
)
ch <- prometheus.MustNewConstMetric(
c.windowsIntegratedAuthentications,
prometheus.CounterValue,
adfsData[0].WindowsIntegratedAuthentications,
)
return nil
}

View File

@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"regexp" "regexp"
"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"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
@@ -27,7 +26,7 @@ var (
).Default("").String() ).Default("").String()
) )
// A LogicalDiskCollector is a Prometheus collector for WMI Win32_PerfRawData_PerfDisk_LogicalDisk metrics // A LogicalDiskCollector is a Prometheus collector for perflib logicalDisk metrics
type LogicalDiskCollector struct { type LogicalDiskCollector struct {
RequestsQueued *prometheus.Desc RequestsQueued *prometheus.Desc
ReadBytesTotal *prometheus.Desc ReadBytesTotal *prometheus.Desc
@@ -159,7 +158,7 @@ func NewLogicalDiskCollector() (Collector, error) {
// Collect sends the metric values for each metric // Collect sends the metric values for each metric
// to the provided prometheus Metric channel. // to the provided prometheus Metric channel.
func (c *LogicalDiskCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error { func (c *LogicalDiskCollector) 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 logical_disk metrics:", desc, err) log.Error("failed collecting logical_disk metrics:", desc, err)
return err return err
} }
@@ -169,28 +168,27 @@ func (c *LogicalDiskCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.
// Win32_PerfRawData_PerfDisk_LogicalDisk docs: // Win32_PerfRawData_PerfDisk_LogicalDisk docs:
// - https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class // - https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class
// - https://msdn.microsoft.com/en-us/library/ms803973.aspx - LogicalDisk object reference // - https://msdn.microsoft.com/en-us/library/ms803973.aspx - LogicalDisk object reference
type Win32_PerfRawData_PerfDisk_LogicalDisk struct { type logicalDisk struct {
Name string Name string
CurrentDiskQueueLength uint32 CurrentDiskQueueLength float64 `perflib:"Current Disk Queue Length"`
DiskReadBytesPerSec uint64 DiskReadBytesPerSec float64 `perflib:"Disk Read Bytes/sec"`
DiskReadsPerSec uint32 DiskReadsPerSec float64 `perflib:"Disk Reads/sec"`
DiskWriteBytesPerSec uint64 DiskWriteBytesPerSec float64 `perflib:"Disk Write Bytes/sec"`
DiskWritesPerSec uint32 DiskWritesPerSec float64 `perflib:"Disk Writes/sec"`
PercentDiskReadTime uint64 PercentDiskReadTime float64 `perflib:"% Disk Read Time"`
PercentDiskWriteTime uint64 PercentDiskWriteTime float64 `perflib:"% Disk Write Time"`
PercentFreeSpace uint32 PercentFreeSpace float64 `perflib:"% Free Space_Base"`
PercentFreeSpace_Base uint32 PercentFreeSpace_Base float64 `perflib:"Free Megabytes"`
PercentIdleTime uint64 PercentIdleTime float64 `perflib:"% Idle Time"`
SplitIOPerSec uint32 SplitIOPerSec float64 `perflib:"Split IO/Sec"`
AvgDiskSecPerRead uint64 AvgDiskSecPerRead float64 `perflib:"Avg. Disk sec/Read"`
AvgDiskSecPerWrite uint64 AvgDiskSecPerWrite float64 `perflib:"Avg. Disk sec/Write"`
AvgDiskSecPerTransfer uint64 AvgDiskSecPerTransfer float64 `perflib:"Avg. Disk sec/Transfer"`
} }
func (c *LogicalDiskCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { func (c *LogicalDiskCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
var dst []Win32_PerfRawData_PerfDisk_LogicalDisk var dst []logicalDisk
q := queryAll(&dst) if err := unmarshalObject(ctx.perfObjects["LogicalDisk"], &dst); err != nil {
if err := wmi.Query(q, &dst); err != nil {
return nil, err return nil, err
} }
@@ -204,98 +202,98 @@ func (c *LogicalDiskCollector) collect(ch chan<- prometheus.Metric) (*prometheus
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.RequestsQueued, c.RequestsQueued,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(volume.CurrentDiskQueueLength), volume.CurrentDiskQueueLength,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ReadBytesTotal, c.ReadBytesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.DiskReadBytesPerSec), volume.DiskReadBytesPerSec,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ReadsTotal, c.ReadsTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.DiskReadsPerSec), volume.DiskReadsPerSec,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WriteBytesTotal, c.WriteBytesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.DiskWriteBytesPerSec), volume.DiskWriteBytesPerSec,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WritesTotal, c.WritesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.DiskWritesPerSec), volume.DiskWritesPerSec,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ReadTime, c.ReadTime,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.PercentDiskReadTime)*ticksToSecondsScaleFactor, volume.PercentDiskReadTime,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WriteTime, c.WriteTime,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.PercentDiskWriteTime)*ticksToSecondsScaleFactor, volume.PercentDiskWriteTime,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreeSpace, c.FreeSpace,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(volume.PercentFreeSpace)*1024*1024, volume.PercentFreeSpace_Base*1024*1024,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.TotalSpace, c.TotalSpace,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(volume.PercentFreeSpace_Base)*1024*1024, volume.PercentFreeSpace*1024*1024,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.IdleTime, c.IdleTime,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.PercentIdleTime)*ticksToSecondsScaleFactor, volume.PercentIdleTime,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SplitIOs, c.SplitIOs,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.SplitIOPerSec), volume.SplitIOPerSec,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ReadLatency, c.ReadLatency,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.AvgDiskSecPerRead), volume.AvgDiskSecPerRead*ticksToSecondsScaleFactor,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WriteLatency, c.WriteLatency,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.AvgDiskSecPerWrite), volume.AvgDiskSecPerWrite*ticksToSecondsScaleFactor,
volume.Name, volume.Name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ReadWriteLatency, c.ReadWriteLatency,
prometheus.CounterValue, prometheus.CounterValue,
float64(volume.AvgDiskSecPerTransfer), volume.AvgDiskSecPerTransfer*ticksToSecondsScaleFactor,
volume.Name, volume.Name,
) )
} }

View File

@@ -6,7 +6,6 @@
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"
) )
@@ -15,7 +14,7 @@ func init() {
Factories["memory"] = NewMemoryCollector Factories["memory"] = NewMemoryCollector
} }
// A MemoryCollector is a Prometheus collector for WMI Win32_PerfRawData_PerfOS_Memory metrics // A MemoryCollector is a Prometheus collector for perflib Memory metrics
type MemoryCollector struct { type MemoryCollector struct {
AvailableBytes *prometheus.Desc AvailableBytes *prometheus.Desc
CacheBytes *prometheus.Desc CacheBytes *prometheus.Desc
@@ -257,247 +256,246 @@ func NewMemoryCollector() (Collector, error) {
// Collect sends the metric values for each metric // Collect sends the metric values for each metric
// to the provided prometheus Metric channel. // to the provided prometheus Metric channel.
func (c *MemoryCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error { func (c *MemoryCollector) 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 memory metrics:", desc, err) log.Error("failed collecting memory metrics:", desc, err)
return err return err
} }
return nil return nil
} }
type Win32_PerfRawData_PerfOS_Memory struct { type memory struct {
AvailableBytes uint64 AvailableBytes float64 `perflib:"Available Bytes"`
AvailableKBytes uint64 AvailableKBytes float64 `perflib:"Available KBytes"`
AvailableMBytes uint64 AvailableMBytes float64 `perflib:"Available MBytes"`
CacheBytes uint64 CacheBytes float64 `perflib:"Cache Bytes"`
CacheBytesPeak uint64 CacheBytesPeak float64 `perflib:"Cache Bytes Peak"`
CacheFaultsPersec uint32 CacheFaultsPersec float64 `perflib:"Cache Faults/sec"`
CommitLimit uint64 CommitLimit float64 `perflib:"Commit Limit"`
CommittedBytes uint64 CommittedBytes float64 `perflib:"Committed Bytes"`
DemandZeroFaultsPersec uint32 DemandZeroFaultsPersec float64 `perflib:"Demand Zero Faults/sec"`
FreeAndZeroPageListBytes uint64 FreeAndZeroPageListBytes float64 `perflib:"Free & Zero Page List Bytes"`
FreeSystemPageTableEntries uint32 FreeSystemPageTableEntries float64 `perflib:"Free System Page Table Entries"`
ModifiedPageListBytes uint64 ModifiedPageListBytes float64 `perflib:"Modified Page List Bytes"`
PageFaultsPersec uint32 PageFaultsPersec float64 `perflib:"Page Faults/sec"`
PageReadsPersec uint32 PageReadsPersec float64 `perflib:"Page Reads/sec"`
PagesInputPersec uint32 PagesInputPersec float64 `perflib:"Pages Input/sec"`
PagesOutputPersec uint32 PagesOutputPersec float64 `perflib:"Pages Output/sec"`
PagesPersec uint32 PagesPersec float64 `perflib:"Pages/sec"`
PageWritesPersec uint32 PageWritesPersec float64 `perflib:"Page Writes/sec"`
PoolNonpagedAllocs uint32 PoolNonpagedAllocs float64 `perflib:"Pool Nonpaged Allocs"`
PoolNonpagedBytes uint64 PoolNonpagedBytes float64 `perflib:"Pool Nonpaged Bytes"`
PoolPagedAllocs uint32 PoolPagedAllocs float64 `perflib:"Pool Paged Allocs"`
PoolPagedBytes uint64 PoolPagedBytes float64 `perflib:"Pool Paged Bytes"`
PoolPagedResidentBytes uint64 PoolPagedResidentBytes float64 `perflib:"Pool Paged Resident Bytes"`
StandbyCacheCoreBytes uint64 StandbyCacheCoreBytes float64 `perflib:"Standby Cache Core Bytes"`
StandbyCacheNormalPriorityBytes uint64 StandbyCacheNormalPriorityBytes float64 `perflib:"Standby Cache Normal Priority Bytes"`
StandbyCacheReserveBytes uint64 StandbyCacheReserveBytes float64 `perflib:"Standby Cache Reserve Bytes"`
SystemCacheResidentBytes uint64 SystemCacheResidentBytes float64 `perflib:"System Cache Resident Bytes"`
SystemCodeResidentBytes uint64 SystemCodeResidentBytes float64 `perflib:"System Code Resident Bytes"`
SystemCodeTotalBytes uint64 SystemCodeTotalBytes float64 `perflib:"System Code Total Bytes"`
SystemDriverResidentBytes uint64 SystemDriverResidentBytes float64 `perflib:"System Driver Resident Bytes"`
SystemDriverTotalBytes uint64 SystemDriverTotalBytes float64 `perflib:"System Driver Total Bytes"`
TransitionFaultsPersec uint32 TransitionFaultsPersec float64 `perflib:"Transition Faults/sec"`
TransitionPagesRePurposedPersec uint32 TransitionPagesRePurposedPersec float64 `perflib:"Transition Pages RePurposed/sec"`
WriteCopiesPersec uint32 WriteCopiesPersec float64 `perflib:"Write Copies/sec"`
} }
func (c *MemoryCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { func (c *MemoryCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
var dst []Win32_PerfRawData_PerfOS_Memory var dst []memory
q := queryAll(&dst) if err := unmarshalObject(ctx.perfObjects["Memory"], &dst); err != nil {
if err := wmi.Query(q, &dst); err != nil {
return nil, err return nil, err
} }
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.AvailableBytes, c.AvailableBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].AvailableBytes), dst[0].AvailableBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CacheBytes, c.CacheBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].CacheBytes), dst[0].CacheBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CacheBytesPeak, c.CacheBytesPeak,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].CacheBytesPeak), dst[0].CacheBytesPeak,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CacheFaultsTotal, c.CacheFaultsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].CacheFaultsPersec), dst[0].CacheFaultsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CommitLimit, c.CommitLimit,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].CommitLimit), dst[0].CommitLimit,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CommittedBytes, c.CommittedBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].CommittedBytes), dst[0].CommittedBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.DemandZeroFaultsTotal, c.DemandZeroFaultsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].DemandZeroFaultsPersec), dst[0].DemandZeroFaultsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreeAndZeroPageListBytes, c.FreeAndZeroPageListBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].FreeAndZeroPageListBytes), dst[0].FreeAndZeroPageListBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.FreeSystemPageTableEntries, c.FreeSystemPageTableEntries,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].FreeSystemPageTableEntries), dst[0].FreeSystemPageTableEntries,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ModifiedPageListBytes, c.ModifiedPageListBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].ModifiedPageListBytes), dst[0].ModifiedPageListBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PageFaultsTotal, c.PageFaultsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PageFaultsPersec), dst[0].PageFaultsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SwapPageReadsTotal, c.SwapPageReadsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PageReadsPersec), dst[0].PageReadsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SwapPagesReadTotal, c.SwapPagesReadTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PagesInputPersec), dst[0].PagesInputPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SwapPagesWrittenTotal, c.SwapPagesWrittenTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PagesOutputPersec), dst[0].PagesOutputPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SwapPageOperationsTotal, c.SwapPageOperationsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PagesPersec), dst[0].PagesPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SwapPageWritesTotal, c.SwapPageWritesTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PageWritesPersec), dst[0].PageWritesPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PoolNonpagedAllocsTotal, c.PoolNonpagedAllocsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PoolNonpagedAllocs), dst[0].PoolNonpagedAllocs,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PoolNonpagedBytes, c.PoolNonpagedBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PoolNonpagedBytes), dst[0].PoolNonpagedBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PoolPagedAllocsTotal, c.PoolPagedAllocsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PoolPagedAllocs), dst[0].PoolPagedAllocs,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PoolPagedBytes, c.PoolPagedBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PoolPagedBytes), dst[0].PoolPagedBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PoolPagedResidentBytes, c.PoolPagedResidentBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].PoolPagedResidentBytes), dst[0].PoolPagedResidentBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.StandbyCacheCoreBytes, c.StandbyCacheCoreBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].StandbyCacheCoreBytes), dst[0].StandbyCacheCoreBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.StandbyCacheNormalPriorityBytes, c.StandbyCacheNormalPriorityBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].StandbyCacheNormalPriorityBytes), dst[0].StandbyCacheNormalPriorityBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.StandbyCacheReserveBytes, c.StandbyCacheReserveBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].StandbyCacheReserveBytes), dst[0].StandbyCacheReserveBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemCacheResidentBytes, c.SystemCacheResidentBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SystemCacheResidentBytes), dst[0].SystemCacheResidentBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemCodeResidentBytes, c.SystemCodeResidentBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SystemCodeResidentBytes), dst[0].SystemCodeResidentBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemCodeTotalBytes, c.SystemCodeTotalBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SystemCodeTotalBytes), dst[0].SystemCodeTotalBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemDriverResidentBytes, c.SystemDriverResidentBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SystemDriverResidentBytes), dst[0].SystemDriverResidentBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemDriverTotalBytes, c.SystemDriverTotalBytes,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].SystemDriverTotalBytes), dst[0].SystemDriverTotalBytes,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.TransitionFaultsTotal, c.TransitionFaultsTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].TransitionFaultsPersec), dst[0].TransitionFaultsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.TransitionPagesRepurposedTotal, c.TransitionPagesRepurposedTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].TransitionPagesRePurposedPersec), dst[0].TransitionPagesRePurposedPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WriteCopiesTotal, c.WriteCopiesTotal,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].WriteCopiesPersec), dst[0].WriteCopiesPersec,
) )
return nil, nil return nil, nil

View File

@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"regexp" "regexp"
"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"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
@@ -28,7 +27,7 @@ var (
nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]") nicNameToUnderscore = regexp.MustCompile("[^a-zA-Z0-9]")
) )
// A NetworkCollector is a Prometheus collector for WMI Win32_PerfRawData_Tcpip_NetworkInterface metrics // A NetworkCollector is a Prometheus collector for Perflib Network Interface metrics
type NetworkCollector struct { type NetworkCollector struct {
BytesReceivedTotal *prometheus.Desc BytesReceivedTotal *prometheus.Desc
BytesSentTotal *prometheus.Desc BytesSentTotal *prometheus.Desc
@@ -133,7 +132,7 @@ func NewNetworkCollector() (Collector, error) {
// Collect sends the metric values for each metric // Collect sends the metric values for each metric
// to the provided prometheus Metric channel. // to the provided prometheus Metric channel.
func (c *NetworkCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error { func (c *NetworkCollector) 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 net metrics:", desc, err) log.Error("failed collecting net metrics:", desc, err)
return err return err
} }
@@ -141,34 +140,33 @@ func (c *NetworkCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr
} }
// mangleNetworkName mangles Network Adapter name (non-alphanumeric to _) // mangleNetworkName mangles Network Adapter name (non-alphanumeric to _)
// that is used in Win32_PerfRawData_Tcpip_NetworkInterface. // that is used in networkInterface.
func mangleNetworkName(name string) string { func mangleNetworkName(name string) string {
return nicNameToUnderscore.ReplaceAllString(name, "_") return nicNameToUnderscore.ReplaceAllString(name, "_")
} }
// Win32_PerfRawData_Tcpip_NetworkInterface docs: // Win32_PerfRawData_Tcpip_NetworkInterface docs:
// - https://technet.microsoft.com/en-us/security/aa394340(v=vs.80) // - https://technet.microsoft.com/en-us/security/aa394340(v=vs.80)
type Win32_PerfRawData_Tcpip_NetworkInterface struct { type networkInterface struct {
BytesReceivedPerSec uint64 BytesReceivedPerSec float64 `perflib:"Bytes Received/sec"`
BytesSentPerSec uint64 BytesSentPerSec float64 `perflib:"Bytes Sent/sec"`
BytesTotalPerSec uint64 BytesTotalPerSec float64 `perflib:"Bytes Total/sec"`
Name string Name string
PacketsOutboundDiscarded uint64 PacketsOutboundDiscarded float64 `perflib:"Packets Outbound Discarded"`
PacketsOutboundErrors uint64 PacketsOutboundErrors float64 `perflib:"Packets Outbound Errors"`
PacketsPerSec uint64 PacketsPerSec float64 `perflib:"Packets/sec"`
PacketsReceivedDiscarded uint64 PacketsReceivedDiscarded float64 `perflib:"Packets Received Discarded"`
PacketsReceivedErrors uint64 PacketsReceivedErrors float64 `perflib:"Packets Received Errors"`
PacketsReceivedPerSec uint64 PacketsReceivedPerSec float64 `perflib:"Packets Received/sec"`
PacketsReceivedUnknown uint64 PacketsReceivedUnknown float64 `perflib:"Packets Received Unknown"`
PacketsSentPerSec uint64 PacketsSentPerSec float64 `perflib:"Packets Sent/sec"`
CurrentBandwidth uint64 CurrentBandwidth float64 `perflib:"Current Bandwidth"`
} }
func (c *NetworkCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { func (c *NetworkCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
var dst []Win32_PerfRawData_Tcpip_NetworkInterface var dst []networkInterface
q := queryAll(&dst) if err := unmarshalObject(ctx.perfObjects["Network Interface"], &dst); err != nil {
if err := wmi.Query(q, &dst); err != nil {
return nil, err return nil, err
} }
@@ -187,76 +185,75 @@ func (c *NetworkCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.BytesReceivedTotal, c.BytesReceivedTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.BytesReceivedPerSec), nic.BytesReceivedPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.BytesSentTotal, c.BytesSentTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.BytesSentPerSec), nic.BytesSentPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.BytesTotal, c.BytesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.BytesTotalPerSec), nic.BytesTotalPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsOutboundDiscarded, c.PacketsOutboundDiscarded,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsOutboundDiscarded), nic.PacketsOutboundDiscarded,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsOutboundErrors, c.PacketsOutboundErrors,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsOutboundErrors), nic.PacketsOutboundErrors,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsTotal, c.PacketsTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsPerSec), nic.PacketsPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsReceivedDiscarded, c.PacketsReceivedDiscarded,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsReceivedDiscarded), nic.PacketsReceivedDiscarded,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsReceivedErrors, c.PacketsReceivedErrors,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsReceivedErrors), nic.PacketsReceivedErrors,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsReceivedTotal, c.PacketsReceivedTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsReceivedPerSec), nic.PacketsReceivedPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsReceivedUnknown, c.PacketsReceivedUnknown,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsReceivedUnknown), nic.PacketsReceivedUnknown,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.PacketsSentTotal, c.PacketsSentTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(nic.PacketsSentPerSec), nic.PacketsSentPerSec,
name, name,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.CurrentBandwidth, c.CurrentBandwidth,
prometheus.CounterValue, prometheus.GaugeValue,
float64(nic.CurrentBandwidth), nic.CurrentBandwidth,
name, name,
) )
} }
return nil, nil return nil, nil
} }

View File

@@ -3,8 +3,6 @@
package collector package collector
import ( import (
"errors"
"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"
) )
@@ -70,7 +68,7 @@ func NewSystemCollector() (Collector, error) {
// Collect sends the metric values for each metric // Collect sends the metric values for each metric
// to the provided prometheus Metric channel. // to the provided prometheus Metric channel.
func (c *SystemCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error { func (c *SystemCollector) 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 system metrics:", desc, err) log.Error("failed collecting system metrics:", desc, err)
return err return err
} }
@@ -79,57 +77,50 @@ func (c *SystemCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metri
// Win32_PerfRawData_PerfOS_System docs: // Win32_PerfRawData_PerfOS_System docs:
// - https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp // - https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp
type Win32_PerfRawData_PerfOS_System struct { type system struct {
ContextSwitchesPersec uint32 ContextSwitchesPersec float64 `perflib:"Context Switches/sec"`
ExceptionDispatchesPersec uint32 ExceptionDispatchesPersec float64 `perflib:"Exception Dispatches/sec"`
Frequency_Object uint64 ProcessorQueueLength float64 `perflib:"Processor Queue Length"`
ProcessorQueueLength uint32 SystemCallsPersec float64 `perflib:"System Calls/sec"`
SystemCallsPersec uint32 SystemUpTime float64 `perflib:"System Up Time"`
SystemUpTime uint64 Threads float64 `perflib:"Threads"`
Threads uint32
Timestamp_Object uint64
} }
func (c *SystemCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { func (c *SystemCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
var dst []Win32_PerfRawData_PerfOS_System var dst []system
q := queryAll(&dst) if err := unmarshalObject(ctx.perfObjects["System"], &dst); err != nil {
if err := wmi.Query(q, &dst); err != nil {
return nil, err return nil, err
} }
if len(dst) == 0 {
return nil, errors.New("WMI query returned empty result set")
}
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ContextSwitchesTotal, c.ContextSwitchesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(dst[0].ContextSwitchesPersec), dst[0].ContextSwitchesPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ExceptionDispatchesTotal, c.ExceptionDispatchesTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(dst[0].ExceptionDispatchesPersec), dst[0].ExceptionDispatchesPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ProcessorQueueLength, c.ProcessorQueueLength,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].ProcessorQueueLength), dst[0].ProcessorQueueLength,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemCallsTotal, c.SystemCallsTotal,
prometheus.CounterValue, prometheus.CounterValue,
float64(dst[0].SystemCallsPersec), dst[0].SystemCallsPersec,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.SystemUpTime, c.SystemUpTime,
prometheus.GaugeValue, prometheus.GaugeValue,
// convert from Windows timestamp (1 jan 1601) to unix timestamp (1 jan 1970) dst[0].SystemUpTime,
float64(dst[0].SystemUpTime-116444736000000000)/float64(dst[0].Frequency_Object),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.Threads, c.Threads,
prometheus.GaugeValue, prometheus.GaugeValue,
float64(dst[0].Threads), dst[0].Threads,
) )
return nil, nil return nil, nil
} }

View File

@@ -136,7 +136,7 @@ func (c *TCPCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.ConnectionsEstablished, c.ConnectionsEstablished,
prometheus.CounterValue, prometheus.GaugeValue,
float64(dst[0].ConnectionsEstablished), float64(dst[0].ConnectionsEstablished),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(

View File

@@ -3,6 +3,7 @@ This directory contains documentation of the collectors in the WMI exporter, wit
# Collectors # Collectors
- [`ad`](collector.ad.md) - [`ad`](collector.ad.md)
- [`adfs`](collector.adfs.md)
- [`cpu`](collector.cpu.md) - [`cpu`](collector.cpu.md)
- [`cs`](collector.cs.md) - [`cs`](collector.cs.md)
- [`dns`](collector.dns.md) - [`dns`](collector.dns.md)

51
docs/collector.adfs.md Normal file
View File

@@ -0,0 +1,51 @@
# adfs collector
The adfs collector exposes metrics about Active Directory Federation Services. Note that this collector has only been tested against ADFS 4.0 (2016).
Other ADFS versions may work but are not tested.
|||
-|-
Metric name prefix | `adfs`
Data source | Perflib
Counters | `AD FS`
Enabled by default? | No
## Flags
None
## Metrics
Name | Description | Type | Labels
-----|-------------|------|-------
`wmi_adfs_ad_login_connection_failures` | Total number of connection failures between the ADFS server and the Active Directory domain controller(s) | counter | None
`wmi_adfs_certificate_authentications` | Total number of [User Certificate](https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/configure-user-certificate-authentication) authentications. I.E. smart cards or mobile devices with provisioned client certificates | counter | None
`wmi_adfs_device_authentications` | Total number of [device authentications](https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/device-authentication-controls-in-ad-fs) (SignedToken, clientTLS, PkeyAuth). Device authentication is only available on ADFS 2016 or later | counter | None
`wmi_adfs_extranet_account_lockouts` | Total number of [extranet lockouts](https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/configure-ad-fs-extranet-smart-lockout-protection). Requires the Extranet Lockout feature to be enabled | counter | None
`wmi_adfs_federated_authentications` | Total number of authentications from federated sources. E.G. Office365 | counter | None
`wmi_adfs_passport_authentications` | Total number of authentications from [Microsoft Passport](https://en.wikipedia.org/wiki/Microsoft_account) (now named Microsoft Account) | counter | None
`wmi_adfs_password_change_failed` | Total number of failed password changes. The Password Change Portal must be enabled in the AD FS Management tool in order to allow user password changes | counter | None
`wmi_adfs_password_change_succeeded` | Total number of succeeded password changes. The Password Change Portal must be enabled in the AD FS Management tool in order to allow user password changes | counter | None
`wmi_adfs_token_requests` | Total number of requested access tokens | counter | None
`wmi_adfs_windows_integrated_authentications` | Total number of Windows integrated authentications using Kerberos or NTLM | counter | None
### Example metric
Show rate of device authentications in AD FS:
```
rate(wmi_adfs_device_authentications)[2m]
```
## Useful queries
## Alerting examples
**prometheus.rules**
```yaml
- alert: "HighExtranetLockouts"
expr: "rate(wmi_adfs_extranet_account_lockouts)[2m] > 100"
for: "10m"
labels:
severity: "high"
annotations:
summary: "High number of AD FS extranet lockouts"
description: "High number of AD FS extranet lockouts may indicate a password spray attack.\n Server: {{ $labels.instance }}\n Number of lockouts: {{ $value }}"
```

View File

@@ -1,4 +1,4 @@
# hyperv collector # hyperv collector
The hyperv collector exposes metrics about the Hyper-V hypervisor The hyperv collector exposes metrics about the Hyper-V hypervisor
@@ -16,81 +16,81 @@ None
Name | Description | Type | Labels Name | Description | Type | Labels
-----|-------------|------|------- -----|-------------|------|-------
`wmi_hyper_health_critical` | _Not yet documented_ | counter | None `wmi_hyperv_health_critical` | _Not yet documented_ | counter | None
`wmi_hyper_health_ok` | _Not yet documented_ | counter | None `wmi_hyperv_health_ok` | _Not yet documented_ | counter | None
`wmi_hyper_vid_physical_pages_allocated` | _Not yet documented_ | counter | `vm` `wmi_hyperv_vid_physical_pages_allocated` | _Not yet documented_ | counter | `vm`
`wmi_hyper_vid_preferred_numa_node_index` | _Not yet documented_ | counter | `vm` `wmi_hyperv_vid_preferred_numa_node_index` | _Not yet documented_ | counter | `vm`
`wmi_hyper_vid_remote_physical_pages` | _Not yet documented_ | counter | `vm` `wmi_hyperv_vid_remote_physical_pages` | _Not yet documented_ | counter | `vm`
`wmi_hyper_root_partition_address_spaces` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_address_spaces` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_attached_devices` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_attached_devices` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_deposited_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_deposited_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_device_dma_errors` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_device_dma_errors` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_device_interrupt_errors` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_device_interrupt_errors` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_device_interrupt_mappings` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_device_interrupt_mappings` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_device_interrupt_throttle_events` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_device_interrupt_throttle_events` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_preferred_numa_node_index` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_preferred_numa_node_index` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_gpa_space_modifications` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_gpa_space_modifications` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_io_tlb_flush_cost` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_io_tlb_flush_cost` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_io_tlb_flush` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_io_tlb_flush` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_recommended_virtual_tlb_size` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_recommended_virtual_tlb_size` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_physical_pages_allocated` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_physical_pages_allocated` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_1G_device_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_1G_device_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_1G_gpa_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_1G_gpa_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_2M_device_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_2M_device_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_2M_gpa_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_2M_gpa_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_4K_device_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_4K_device_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_4K_gpa_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_4K_gpa_pages` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_virtual_tlb_flush_entires` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_virtual_tlb_flush_entires` | _Not yet documented_ | counter | None
`wmi_hyper_root_partition_virtual_tlb_pages` | _Not yet documented_ | counter | None `wmi_hyperv_root_partition_virtual_tlb_pages` | _Not yet documented_ | counter | None
`wmi_hyper_hypervisor_virtual_processors` | _Not yet documented_ | counter | None `wmi_hyperv_hypervisor_virtual_processors` | _Not yet documented_ | counter | None
`wmi_hyper_hypervisor_logical_processors` | _Not yet documented_ | counter | None `wmi_hyperv_hypervisor_logical_processors` | _Not yet documented_ | counter | None
`wmi_hyper_host_cpu_guest_run_time` | _Not yet documented_ | counter | `core` `wmi_hyperv_host_cpu_guest_run_time` | _Not yet documented_ | counter | `core`
`wmi_hyper_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core` `wmi_hyperv_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core`
`wmi_hyper_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core` `wmi_hyperv_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core`
`wmi_hyper_host_cpu_total_run_time` | _Not yet documented_ | counter | `core` `wmi_hyperv_host_cpu_total_run_time` | _Not yet documented_ | counter | `core`
`wmi_hyper_vm_cpu_guest_run_time` | _Not yet documented_ | counter | `vm`, `core` `wmi_hyperv_vm_cpu_guest_run_time` | _Not yet documented_ | counter | `vm`, `core`
`wmi_hyper_vm_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `vm`, `core` `wmi_hyperv_vm_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `vm`, `core`
`wmi_hyper_vm_cpu_remote_run_time` | _Not yet documented_ | counter | `vm`, `core` `wmi_hyperv_vm_cpu_remote_run_time` | _Not yet documented_ | counter | `vm`, `core`
`wmi_hyper_vm_cpu_total_run_time` | _Not yet documented_ | counter | `vm`, `core` `wmi_hyperv_vm_cpu_total_run_time` | _Not yet documented_ | counter | `vm`, `core`
`wmi_hyper_vswitch_broadcast_packets_received_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_broadcast_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_broadcast_packets_sent_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_broadcast_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_bytes_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_bytes_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_bytes_received_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_bytes_received_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_bytes_sent_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_bytes_sent_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_directed_packets_received_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_directed_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_directed_packets_send_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_directed_packets_send_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_extensions_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_extensions_dropped_packets_incoming_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_extensions_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_extensions_dropped_packets_outcoming_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_learned_mac_addresses_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_learned_mac_addresses_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_multicast_packets_received_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_multicast_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_multicast_packets_sent_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_multicast_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_number_of_send_channel_moves_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_number_of_send_channel_moves_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_number_of_vmq_moves_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_number_of_vmq_moves_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_packets_flooded_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_packets_flooded_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_packets_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_packets_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_packets_received_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_packets_received_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_packets_sent_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_packets_sent_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_vswitch_purged_mac_addresses_total` | _Not yet documented_ | counter | `vswitch` `wmi_hyperv_vswitch_purged_mac_addresses_total` | _Not yet documented_ | counter | `vswitch`
`wmi_hyper_ethernet_bytes_dropped` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_bytes_dropped` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_ethernet_bytes_received` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_bytes_received` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_ethernet_bytes_sent` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_bytes_sent` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_ethernet_frames_dropped` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_frames_dropped` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_ethernet_frames_received` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_frames_received` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_ethernet_frames_sent` | _Not yet documented_ | counter | `adapter` `wmi_hyperv_ethernet_frames_sent` | _Not yet documented_ | counter | `adapter`
`wmi_hyper_vm_device_error_count` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_error_count` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_device_queue_length` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_queue_length` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_device_bytes_read` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_bytes_read` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_device_operations_read` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_operations_read` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_device_bytes_written` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_bytes_written` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_device_operations_written` | _Not yet documented_ | counter | `vm_device` `wmi_hyperv_vm_device_operations_written` | _Not yet documented_ | counter | `vm_device`
`wmi_hyper_vm_interface_bytes_received` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_bytes_received` | _Not yet documented_ | counter | `vm_interface`
`wmi_hyper_vm_interface_bytes_sent` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_bytes_sent` | _Not yet documented_ | counter | `vm_interface`
`wmi_hyper_vm_interface_packets_incoming_dropped` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_packets_incoming_dropped` | _Not yet documented_ | counter | `vm_interface`
`wmi_hyper_vm_interface_packets_outgoing_dropped` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_packets_outgoing_dropped` | _Not yet documented_ | counter | `vm_interface`
`wmi_hyper_vm_interface_packets_received` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_packets_received` | _Not yet documented_ | counter | `vm_interface`
`wmi_hyper_vm_interface_packets_sent` | _Not yet documented_ | counter | `vm_interface` `wmi_hyperv_vm_interface_packets_sent` | _Not yet documented_ | counter | `vm_interface`
### Example metric ### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_ _This collector does not yet have explained examples, we would appreciate your help adding them!_

View File

@@ -5,7 +5,8 @@ The logical_disk collector exposes metrics about logical disks (in contrast to p
||| |||
-|- -|-
Metric name prefix | `logical_disk` Metric name prefix | `logical_disk`
Classes | [`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)) Data source | Perflib
Counters | `LogicalDisk` ([`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)))
Enabled by default? | Yes Enabled by default? | Yes
## Flags ## Flags

View File

@@ -5,6 +5,7 @@ The memory collector exposes metrics about system memory usage
||| |||
-|- -|-
Metric name prefix | `memory` Metric name prefix | `memory`
Data source | Perflib
Classes | `Win32_PerfRawData_PerfOS_Memory` Classes | `Win32_PerfRawData_PerfOS_Memory`
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -5,6 +5,7 @@ The net collector exposes metrics about network interfaces
||| |||
-|- -|-
Metric name prefix | `net` Metric name prefix | `net`
Data source | Perflib
Classes | [`Win32_PerfRawData_Tcpip_NetworkInterface`](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80)) Classes | [`Win32_PerfRawData_Tcpip_NetworkInterface`](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80))
Enabled by default? | Yes Enabled by default? | Yes
@@ -33,7 +34,7 @@ Name | Description | Type | Labels
`wmi_net_packets_received_unknown` | Total packets received by interface that were discarded because of an unknown or unsupported protocol | counter | `nic` `wmi_net_packets_received_unknown` | Total packets received by interface that were discarded because of an unknown or unsupported protocol | counter | `nic`
`wmi_net_packets_total` | Total packets received and transmitted by interface | counter | `nic` `wmi_net_packets_total` | Total packets received and transmitted by interface | counter | `nic`
`wmi_net_packets_sent_total` | Total packets transmitted by interface | counter | `nic` `wmi_net_packets_sent_total` | Total packets transmitted by interface | counter | `nic`
`wmi_net_current_bandwidth` | Estimate of the interface's current bandwidth in bits per second (bps) | counter | `nic` `wmi_net_current_bandwidth` | Estimate of the interface's current bandwidth in bits per second (bps) | gauge | `nic`
### Example metric ### Example metric
Query the rate of transmitted network traffic Query the rate of transmitted network traffic

View File

@@ -16,24 +16,50 @@ None
Name | Description | Type | Labels Name | Description | Type | Labels
-----|-------------|------|------- -----|-------------|------|-------
`wmi_os_paging_limit_bytes` | _Not yet documented_ | gauge | None `wmi_os_paging_limit_bytes` | Total number of bytes that can be sotred in the operating system paging files. 0 (zero) indicates that there are no paging files | gauge | None
`wmi_os_paging_free_bytes` | _Not yet documented_ | gauge | None `wmi_os_paging_free_bytes` | Number of bytes that can be mapped into the operating system paging files without causing any other pages to be swapped out | gauge | None
`wmi_os_physical_memory_free_bytes` | _Not yet documented_ | gauge | None `wmi_os_physical_memory_free_bytes` | Bytes of physical memory currently unused and available | gauge | None
`wmi_os_time` | _Not yet documented_ | gauge | None `wmi_os_time` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.Unix()](https://golang.org/pkg/time/#Unix) for details | gauge | None
`wmi_os_timezone` | _Not yet documented_ | gauge | `timezone` `wmi_os_timezone` | Current timezone as reported by the operating system. See [time.Zone()](https://golang.org/pkg/time/#Time.Zone) for details | gauge | `timezone`
`wmi_os_processes` | _Not yet documented_ | gauge | None `wmi_os_processes` | Number of process contexts currently loaded or running on the operating system | gauge | None
`wmi_os_processes_limit` | _Not yet documented_ | gauge | None `wmi_os_processes_limit` | Maximum number of process contexts the operating system can support. The default value set by the provider is 4294967295 (0xFFFFFFFF) | gauge | None
`wmi_os_process_memory_limix_bytes` | _Not yet documented_ | gauge | None `wmi_os_process_memory_limit_bytes` | Maximum number of bytes of memory that can be allocated to a process | gauge | None
`wmi_os_users` | _Not yet documented_ | gauge | None `wmi_os_users` | Number of user sessions for which the operating system is storing state information currently. For a list of current active logon sessions, see [`logon`](collector.logon.md) | gauge | None
`wmi_os_virtual_memory_bytes` | _Not yet documented_ | gauge | None `wmi_os_virtual_memory_bytes` | Bytes of virtual memory | gauge | None
`wmi_os_visible_memory_bytes` | _Not yet documented_ | gauge | None `wmi_os_visible_memory_bytes` | Total bytes of physical memory available to the operating system. This value does not necessarily indicate the true amount of physical memory, but what is reported to the operating system as available to it | gauge | None
`wmi_os_virtual_memory_free_bytes` | _Not yet documented_ | gauge | None `wmi_os_virtual_memory_free_bytes` | Bytes of virtual memory currently unused and available | gauge | None
### Example metric ### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_ Show current number of processes
```
wmi_os_processes{instance="localhost"}
```
## Useful queries ## Useful queries
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_ Find all devices not set to UTC timezone
```
wmi_os_timezone{timezone != "UTC"}
```
## Alerting examples ## Alerting examples
_This collector does not yet have alerting examples, we would appreciate your help adding them!_ **prometheus.rules**
```
# Alert on hosts that have exhausted all available physical memory
- alert: MemoryExhausted
expr: wmi_os_physical_memory_free_bytes == 0
for: 10m
labels:
severity: high
annotations:
summary: "Host {{ $labels.instance }} is out of memory"
description: "{{ $labels.instance }} has exhausted all available physical memory"
# Alert on hosts with greater than 90% memory usage
- alert: MemoryLow
expr: 100 - 100 * wmi_os_physical_memory_free_bytes / wmi_cs_physical_memory_bytes > 90
for: 10m
labels:
severity: warning
annotations:
summary: "Memory usage for host {{ $labels.instance }} is greater than 90%"
```

View File

@@ -5,6 +5,7 @@ The system collector exposes metrics about ...
||| |||
-|- -|-
Metric name prefix | `system` Metric name prefix | `system`
Data source | Perflib
Classes | [`Win32_PerfRawData_PerfOS_System`](https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp) Classes | [`Win32_PerfRawData_PerfOS_System`](https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -16,15 +16,15 @@ None
Name | Description | Type | Labels Name | Description | Type | Labels
-----|-------------|------|------- -----|-------------|------|-------
`wmi_tcp_connection_failures` | _Not yet documented_ | counter | None `wmi_tcp_connection_failures` | Number of times TCP connections have made a direct transition to the CLOSED state from the SYN-SENT state or the SYN-RCVD state, plus the number of times TCP connections have made a direct transition from the SYN-RCVD state to the LISTEN state | counter | None
`wmi_tcp_connections_active` | _Not yet documented_ | counter | None `wmi_tcp_connections_active` | Number of times TCP connections have made a direct transition from the CLOSED state to the SYN-SENT state.| counter | None
`wmi_tcp_connections_established` | _Not yet documented_ | counter | None `wmi_tcp_connections_established` | Number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT. | counter | None
`wmi_tcp_connections_passive` | _Not yet documented_ | counter | None `wmi_tcp_connections_passive` | Number of times TCP connections have made a direct transition from the LISTEN state to the SYN-RCVD state. | counter | None
`wmi_tcp_connections_reset` | _Not yet documented_ | counter | None `wmi_tcp_connections_reset` | Number of times TCP connections have made a direct transition from the LISTEN state to the SYN-RCVD state. | counter | None
`wmi_tcp_segments_total` | _Not yet documented_ | counter | None `wmi_tcp_segments_total` | Total segments sent or received using the TCP protocol | counter | None
`wmi_tcp_segments_received_total` | _Not yet documented_ | counter | None `wmi_tcp_segments_received_total` | Total segments received, including those received in error. This count includes segments received on currently established connections | counter | None
`wmi_tcp_segments_retransmitted_total` | _Not yet documented_ | counter | None `wmi_tcp_segments_retransmitted_total` | Total segments retransmitted. That is, segments transmitted that contain one or more previously transmitted bytes | counter | None
`wmi_tcp_segments_sent_total` | _Not yet documented_ | counter | None `wmi_tcp_segments_sent_total` | Total segments sent, including those on current connections, but excluding those containing *only* retransmitted bytes | counter | None
### Example metric ### Example metric
_This collector does not yet have explained examples, we would appreciate your help adding them!_ _This collector does not yet have explained examples, we would appreciate your help adding them!_

View File

@@ -12,7 +12,7 @@ Enabled by default? | Yes
### `--collector.textfile.directory` ### `--collector.textfile.directory`
The directory containing the files to be ingested. Only files with the extension `.prom` are read. The directory containing the files to be ingested. Only files with the extension `.prom` are read. The `.prom` file must end with an empty line feed to work properly.
Default value: `C:\Program Files\wmi_exporter\textfile_inputs` Default value: `C:\Program Files\wmi_exporter\textfile_inputs`