mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-16 17:56:37 +00:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
922c08b85b | ||
|
|
a3867b8dbf | ||
|
|
3b2ef6287c | ||
|
|
8d0d7b31b1 | ||
|
|
24470eb17e | ||
|
|
6bcaee5885 | ||
|
|
ea557547dd | ||
|
|
3c90b96cc6 | ||
|
|
a03f9ef01b | ||
|
|
391335a91f | ||
|
|
6367863c43 | ||
|
|
5c7c0aaa69 | ||
|
|
51f1f884e7 | ||
|
|
7d2511b7ab | ||
|
|
f1384759cb | ||
|
|
3316dc502d | ||
|
|
c9f1e5068a | ||
|
|
86dc495aeb | ||
|
|
418b5b3ca9 | ||
|
|
f2d8418e9f | ||
|
|
0fbdfae85c | ||
|
|
501ac3da4c | ||
|
|
dd6bfbe963 | ||
|
|
a4f815b5fd | ||
|
|
44d419e8fa | ||
|
|
cd8d676443 |
3
CODE_OF_CONDUCT.md
Normal file
3
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
## Prometheus Community Code of Conduct
|
||||||
|
|
||||||
|
Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
Contributors in alphabetical order
|
Contributors in alphabetical order
|
||||||
|
|
||||||
|
* [Brian Brazil](https://github.com/brian-brazil)
|
||||||
* [Martin Lindhe](https://github.com/martinlindhe)
|
* [Martin Lindhe](https://github.com/martinlindhe)
|
||||||
* [Calle Pettersson](https://github.com/carlpett)
|
* [Calle Pettersson](https://github.com/carlpett)
|
||||||
17
README.md
17
README.md
@@ -14,8 +14,10 @@ Name | Description | Enabled by default
|
|||||||
[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 |
|
||||||
|
[dhcp](docs/collector.dhcp.md) | DHCP Server |
|
||||||
[dns](docs/collector.dns.md) | DNS Server |
|
[dns](docs/collector.dns.md) | DNS Server |
|
||||||
[exchange](docs/collector.exchange.md) | Exchange metrics |
|
[exchange](docs/collector.exchange.md) | Exchange metrics |
|
||||||
|
[fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector |
|
||||||
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
|
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
|
||||||
[iis](docs/collector.iis.md) | IIS sites and applications |
|
[iis](docs/collector.iis.md) | IIS sites and applications |
|
||||||
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓
|
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓
|
||||||
@@ -45,6 +47,19 @@ Name | Description | Enabled by default
|
|||||||
|
|
||||||
See the linked documentation on each collector for more information on reported metrics, configuration settings and usage examples.
|
See the linked documentation on each collector for more information on reported metrics, configuration settings and usage examples.
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
windows_exporter accepts flags to configure certain behaviours. The ones configuring the global behaviour of the exporter are listed below, while collector-specific ones are documented in the respective collector documentation above.
|
||||||
|
|
||||||
|
Flag | Description | Default value
|
||||||
|
---------|-------------|--------------------
|
||||||
|
`--telemetry.addr` | host:port for exporter. | `:9182`
|
||||||
|
`--telemetry.path` | URL path for surfacing collected metrics. | `/metrics`
|
||||||
|
`--telemetry.max-requests` | Maximum number of concurrent requests. 0 to disable. | `5`
|
||||||
|
`--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder for all the collectors enabled by default." | `[defaults]`
|
||||||
|
`--collectors.print` | If true, print available collectors and exit. |
|
||||||
|
`--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5`
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
The latest release can be downloaded from the [releases page](https://github.com/prometheus-community/windows_exporter/releases).
|
The latest release can be downloaded from the [releases page](https://github.com/prometheus-community/windows_exporter/releases).
|
||||||
|
|
||||||
@@ -87,7 +102,7 @@ See [open issues](https://github.com/prometheus-community/windows_exporter/issue
|
|||||||
go get -u github.com/prometheus/promu
|
go get -u github.com/prometheus/promu
|
||||||
go get -u github.com/prometheus-community/windows_exporter
|
go get -u github.com/prometheus-community/windows_exporter
|
||||||
cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter
|
cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter
|
||||||
promu build -v .
|
promu build -v
|
||||||
.\windows_exporter.exe
|
.\windows_exporter.exe
|
||||||
|
|
||||||
The prometheus metrics will be exposed on [localhost:9182](http://localhost:9182)
|
The prometheus metrics will be exposed on [localhost:9182](http://localhost:9182)
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ var (
|
|||||||
|
|
||||||
func registerCollector(name string, builder collectorBuilder, perfCounterNames ...string) {
|
func registerCollector(name string, builder collectorBuilder, perfCounterNames ...string) {
|
||||||
builders[name] = builder
|
builders[name] = builder
|
||||||
|
addPerfCounterDependencies(name, perfCounterNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addPerfCounterDependencies(name string, perfCounterNames []string) {
|
||||||
perfIndicies := make([]string, 0, len(perfCounterNames))
|
perfIndicies := make([]string, 0, len(perfCounterNames))
|
||||||
for _, cn := range perfCounterNames {
|
for _, cn := range perfCounterNames {
|
||||||
perfIndicies = append(perfIndicies, MapCounterToIndex(cn))
|
perfIndicies = append(perfIndicies, MapCounterToIndex(cn))
|
||||||
@@ -109,3 +113,9 @@ func PrepareScrapeContext(collectors []string) (*ScrapeContext, error) {
|
|||||||
|
|
||||||
return &ScrapeContext{objs}, nil
|
return &ScrapeContext{objs}, nil
|
||||||
}
|
}
|
||||||
|
func boolToFloat(b bool) float64 {
|
||||||
|
if b {
|
||||||
|
return 1.0
|
||||||
|
}
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ func NewDhcpCollector() (Collector, error) {
|
|||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
DeniedDueToNonMatch: prometheus.NewDesc(
|
DeniedDueToNonMatch: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "denied_due_to_match_total"),
|
prometheus.BuildFQName(Namespace, subsystem, "denied_due_to_nonmatch_total"),
|
||||||
"Total number of DHCP requests denied, based on non-matches from the Allow list (DeniedDueToNonMatch)",
|
"Total number of DHCP requests denied, based on non-matches from the Allow list (DeniedDueToNonMatch)",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
|
|||||||
187
collector/fsrmquota.go
Normal file
187
collector/fsrmquota.go
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
package collector
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/StackExchange/wmi"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/common/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerCollector("fsrmquota", newFSRMQuotaCollector)
|
||||||
|
}
|
||||||
|
|
||||||
|
type FSRMQuotaCollector struct {
|
||||||
|
QuotasCount *prometheus.Desc
|
||||||
|
Path *prometheus.Desc
|
||||||
|
PeakUsage *prometheus.Desc
|
||||||
|
Size *prometheus.Desc
|
||||||
|
Usage *prometheus.Desc
|
||||||
|
|
||||||
|
Description *prometheus.Desc
|
||||||
|
Disabled *prometheus.Desc
|
||||||
|
MatchesTemplate *prometheus.Desc
|
||||||
|
SoftLimit *prometheus.Desc
|
||||||
|
Template *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
func newFSRMQuotaCollector() (Collector, error) {
|
||||||
|
const subsystem = "fsrmquota"
|
||||||
|
return &FSRMQuotaCollector{
|
||||||
|
QuotasCount: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "count"),
|
||||||
|
"Number of Quotas",
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
PeakUsage: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "peak_usage_bytes"),
|
||||||
|
"The highest amount of disk space usage charged to this quota. (PeakUsage)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
Size: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "size_bytes"),
|
||||||
|
"The size of the quota. (Size)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
Usage: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "usage_bytes"),
|
||||||
|
"The current amount of disk space usage charged to this quota. (Usage)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
Description: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "description"),
|
||||||
|
"Description of the quota (Description)",
|
||||||
|
[]string{"path", "template", "description"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
Disabled: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "disabled"),
|
||||||
|
"If 1, the quota is disabled. The default value is 0. (Disabled)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
SoftLimit: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "softlimit"),
|
||||||
|
"If 1, the quota is a soft limit. If 0, the quota is a hard limit. The default value is 0. Optional (SoftLimit)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
Template: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "template"),
|
||||||
|
"Quota template name. (Template)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
MatchesTemplate: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(Namespace, subsystem, "matchestemplate"),
|
||||||
|
"If 1, the property values of this quota match those values of the template from which it was derived. (MatchesTemplate)",
|
||||||
|
[]string{"path", "template"},
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect sends the metric values for each metric
|
||||||
|
// to the provided prometheus Metric channel.
|
||||||
|
func (c *FSRMQuotaCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||||
|
if desc, err := c.collect(ch); err != nil {
|
||||||
|
log.Error("failed collecting fsrmquota metrics:", desc, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MSFT_FSRMQuota docs:
|
||||||
|
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/fsrm/msft-fsrmquota
|
||||||
|
type MSFT_FSRMQuota struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
Path string
|
||||||
|
PeakUsage uint64
|
||||||
|
Size uint64
|
||||||
|
Usage uint64
|
||||||
|
Description string
|
||||||
|
Template string
|
||||||
|
//Threshold string
|
||||||
|
Disabled bool
|
||||||
|
MatchesTemplate bool
|
||||||
|
SoftLimit bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *FSRMQuotaCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
||||||
|
var dst []MSFT_FSRMQuota
|
||||||
|
q := queryAll(&dst)
|
||||||
|
|
||||||
|
var count int
|
||||||
|
|
||||||
|
if err := wmi.QueryNamespace(q, &dst, "root/microsoft/windows/fsrm"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, quota := range dst {
|
||||||
|
|
||||||
|
count++
|
||||||
|
path := quota.Path
|
||||||
|
template := quota.Template
|
||||||
|
Description := quota.Description
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.PeakUsage,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(quota.PeakUsage),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.Size,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(quota.Size),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.Usage,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(quota.Usage),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.Description,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
1.0,
|
||||||
|
path, template, Description,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.Disabled,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
boolToFloat(quota.Disabled),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.MatchesTemplate,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
boolToFloat(quota.MatchesTemplate),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.SoftLimit,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
boolToFloat(quota.SoftLimit),
|
||||||
|
path,
|
||||||
|
template,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.QuotasCount,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(count),
|
||||||
|
)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
2822
collector/mssql.go
2822
collector/mssql.go
File diff suppressed because it is too large
Load Diff
@@ -45,7 +45,7 @@ func NewserviceCollector() (Collector, error) {
|
|||||||
Information: prometheus.NewDesc(
|
Information: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(Namespace, subsystem, "info"),
|
prometheus.BuildFQName(Namespace, subsystem, "info"),
|
||||||
"A metric with a constant '1' value labeled with service information",
|
"A metric with a constant '1' value labeled with service information",
|
||||||
[]string{"name", "display_name", "process_id"},
|
[]string{"name", "display_name", "process_id", "run_as"},
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
State: prometheus.NewDesc(
|
State: prometheus.NewDesc(
|
||||||
@@ -89,6 +89,7 @@ type Win32_Service struct {
|
|||||||
State string
|
State string
|
||||||
Status string
|
Status string
|
||||||
StartMode string
|
StartMode string
|
||||||
|
StartName *string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -131,9 +132,13 @@ func (c *serviceCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
|
|||||||
if err := wmi.Query(q, &dst); err != nil {
|
if err := wmi.Query(q, &dst); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, service := range dst {
|
for _, service := range dst {
|
||||||
pid := strconv.FormatUint(uint64(service.ProcessId), 10)
|
pid := strconv.FormatUint(uint64(service.ProcessId), 10)
|
||||||
|
|
||||||
|
runAs := ""
|
||||||
|
if service.StartName != nil {
|
||||||
|
runAs = *service.StartName
|
||||||
|
}
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.Information,
|
c.Information,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -141,6 +146,7 @@ func (c *serviceCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
|
|||||||
strings.ToLower(service.Name),
|
strings.ToLower(service.Name),
|
||||||
service.DisplayName,
|
service.DisplayName,
|
||||||
pid,
|
pid,
|
||||||
|
runAs,
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, state := range allStates {
|
for _, state := range allStates {
|
||||||
|
|||||||
52
docs/collector.fsrmquota.md
Normal file
52
docs/collector.fsrmquota.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Microsoft File Server Resource Manager (FSRM) Quotas collector
|
||||||
|
|
||||||
|
The fsrmquota collector exposes metrics about File Server Ressource Manager Quotas. Note that this collector has only been tested against Windows server 2012R2.
|
||||||
|
Other FSRM versions may work but are not tested.
|
||||||
|
|
||||||
|
|||
|
||||||
|
-|-
|
||||||
|
Metric name prefix | `fsrmquota`
|
||||||
|
Data source | wmi
|
||||||
|
Counters | `FSRMQUOTA`
|
||||||
|
Enabled by default? | No
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
## Metrics
|
||||||
|
|
||||||
|
Name | Description | Type | Labels
|
||||||
|
-----|-------------|------|-------
|
||||||
|
|
||||||
|
`windows_fsrmquota_count` | Number of Quotas | counter |None
|
||||||
|
`windows_fsrmquota_description` | A string up to 1KB in size. Optional. The default value is an empty string. (Description) | counter |`path`, `template`,`description`
|
||||||
|
`windows_fsrmquota_disabled` | If 1, the quota is disabled. The default value is 0. (Disabled) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_matchestemplate` | If 1, the property values of this quota match those values of the template from which it was derived. (MatchesTemplate) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_peak_usage_bytes ` | The highest amount of disk space usage charged to this quota. (PeakUsage) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_size_bytes` | The size of the quota. If the Template property is not provided then the Size property must be provided (Size) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_softlimit` | If 1, the quota is a soft limit. If 0, the quota is a hard limit. The default value is 0. Optional (SoftLimit) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_template` | A valid quota template name. Up to 1KB in size. Optional (Template) | counter |`path`, `template`
|
||||||
|
`windows_fsrmquota_usage_bytes` | The current amount of disk space usage charged to this quota. (Usage) | counter |`path`, `template`
|
||||||
|
|
||||||
|
|
||||||
|
### Example metric
|
||||||
|
Show rate of Quotas usage:
|
||||||
|
```
|
||||||
|
rate(windows_fsrmquota_usage_bytes)[1d]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Useful queries
|
||||||
|
|
||||||
|
## Alerting examples
|
||||||
|
**prometheus.rules**
|
||||||
|
```yaml
|
||||||
|
- alert: "HighQuotasUsage"
|
||||||
|
expr: "windows_fsrmquota_usage_bytes{instance="SERVER1.COM:9182"} / windows_fsrmquota_size{instance="SERVER1.COM:9182"} >0.85"
|
||||||
|
for: "10m"
|
||||||
|
labels:
|
||||||
|
severity: "high"
|
||||||
|
annotations:
|
||||||
|
summary: "High Quotas Usage"
|
||||||
|
description: "High use of File Ressource.\n Quotas: {{ $labels.path }}\n Current use : {{ $value }}"
|
||||||
|
```
|
||||||
@@ -96,7 +96,18 @@ Name | Description | Type | Labels
|
|||||||
_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!_
|
||||||
|
|
||||||
## Useful queries
|
## Useful queries
|
||||||
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
|
Percent of physical CPU resources used per VM (on instance "localhost")
|
||||||
|
```
|
||||||
|
(sum (rate(windows_hyperv_vm_cpu_hypervisor_run_time{instance="localhost"}[1m]))) / ignoring(vm) group_left max (windows_cs_logical_processors{instance="localhost"}) / 100000
|
||||||
|
```
|
||||||
|
Percent of physical CPU resources used by all VMs (on all monitored hosts)
|
||||||
|
```
|
||||||
|
(sum by (instance)(rate(windows_hyperv_vm_cpu_total_run_time{}[1m]))) / max by (instance)(windows_cs_logical_processors{}) / 100000
|
||||||
|
```
|
||||||
|
Percent of physical CPU resources by the hosts themselves (on all monitored hosts)
|
||||||
|
```
|
||||||
|
(sum by (instance)(rate(windows_hyperv_host_cpu_total_run_time{}[1m]))) / sum by (instance)(windows_cs_logical_processors{}) / 100000
|
||||||
|
```
|
||||||
|
|
||||||
## Alerting examples
|
## Alerting examples
|
||||||
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ Example: `--collector.service.services-where="Name='windows_exporter'"`
|
|||||||
|
|
||||||
Name | Description | Type | Labels
|
Name | Description | Type | Labels
|
||||||
-----|-------------|------|-------
|
-----|-------------|------|-------
|
||||||
`windows_service_info` | Contains service information in labels, constant 1 | gauge | name, display_name, process_id
|
`windows_service_info` | Contains service information in labels, constant 1 | gauge | name, display_name, process_id, run_as
|
||||||
`windows_service_state` | The state of the service, 1 if the current state, 0 otherwise | gauge | name, state
|
`windows_service_state` | The state of the service, 1 if the current state, 0 otherwise | gauge | name, state
|
||||||
`windows_service_start_mode` | The start mode of the service, 1 if the current start mode, 0 otherwise | gauge | name, start_mode
|
`windows_service_start_mode` | The start mode of the service, 1 if the current start mode, 0 otherwise | gauge | name, start_mode
|
||||||
`windows_service_status` | The status of the service, 1 if the current status, 0 otherwise | gauge | name, status
|
`windows_service_status` | The status of the service, 1 if the current status, 0 otherwise | gauge | name, status
|
||||||
|
|
||||||
For the values of the `state`, `start_mode` and `status` labels, see below.
|
For the values of the `state`, `start_mode`, `status` and `run_as` labels, see below.
|
||||||
|
|
||||||
### States
|
### States
|
||||||
|
|
||||||
@@ -66,6 +66,13 @@ A service can have any of the following statuses:
|
|||||||
|
|
||||||
Note that there is some overlap with service state.
|
Note that there is some overlap with service state.
|
||||||
|
|
||||||
|
### Run As
|
||||||
|
|
||||||
|
Account name under which a service runs. Depending on the service type, the account name may be in the form of "DomainName\Username" or UPN format ("Username@DomainName").
|
||||||
|
|
||||||
|
It corresponds to the `StartName` attribute of the `Win32_Service` class.
|
||||||
|
`StartName` attribute can be NULL and in such case the label is reported as an empty string. Notice that if the attribute is NULL the service is logged on as the `LocalSystem` account or, for kernel or system-level drive, it runs with a default object name created by the I/O system based on the service name, for example, DWDOM\Admin.
|
||||||
|
|
||||||
### Example metric
|
### Example metric
|
||||||
Lists the services that have a 'disabled' start mode.
|
Lists the services that have a 'disabled' start mode.
|
||||||
```
|
```
|
||||||
|
|||||||
27
exporter.go
27
exporter.go
@@ -3,6 +3,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@@ -28,6 +29,17 @@ type windowsCollector struct {
|
|||||||
collectors map[string]collector.Collector
|
collectors map[string]collector.Collector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same struct prometheus uses for their /version endpoint.
|
||||||
|
// Separate copy to avoid pulling all of prometheus as a dependency
|
||||||
|
type prometheusVersion struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
Revision string `json:"revision"`
|
||||||
|
Branch string `json:"branch"`
|
||||||
|
BuildUser string `json:"buildUser"`
|
||||||
|
BuildDate string `json:"buildDate"`
|
||||||
|
GoVersion string `json:"goVersion"`
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultCollectors = "cpu,cs,logical_disk,net,os,service,system,textfile"
|
defaultCollectors = "cpu,cs,logical_disk,net,os,service,system,textfile"
|
||||||
defaultCollectorsPlaceholder = "[defaults]"
|
defaultCollectorsPlaceholder = "[defaults]"
|
||||||
@@ -337,6 +349,21 @@ func main() {
|
|||||||
|
|
||||||
http.HandleFunc(*metricsPath, withConcurrencyLimit(*maxRequests, h.ServeHTTP))
|
http.HandleFunc(*metricsPath, withConcurrencyLimit(*maxRequests, h.ServeHTTP))
|
||||||
http.HandleFunc("/health", healthCheck)
|
http.HandleFunc("/health", healthCheck)
|
||||||
|
http.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// we can't use "version" directly as it is a package, and not an object that
|
||||||
|
// can be serialized.
|
||||||
|
err := json.NewEncoder(w).Encode(prometheusVersion{
|
||||||
|
Version: version.Version,
|
||||||
|
Revision: version.Revision,
|
||||||
|
Branch: version.Branch,
|
||||||
|
BuildUser: version.BuildUser,
|
||||||
|
BuildDate: version.BuildDate,
|
||||||
|
GoVersion: version.GoVersion,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("error encoding JSON: %s", err), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
})
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
_, _ = w.Write([]byte(`<html>
|
_, _ = w.Write([]byte(`<html>
|
||||||
<head><title>windows_exporter</title></head>
|
<head><title>windows_exporter</title></head>
|
||||||
|
|||||||
Reference in New Issue
Block a user