mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-18 10:46:35 +00:00
Merge pull request #1062 from breed808/process_wmi
feat!: Disable IIS queries in `process` collector
This commit is contained in:
@@ -34,6 +34,8 @@ var (
|
|||||||
|
|
||||||
processIncludeSet bool
|
processIncludeSet bool
|
||||||
processExcludeSet bool
|
processExcludeSet bool
|
||||||
|
|
||||||
|
enableWorkerProcess *bool
|
||||||
)
|
)
|
||||||
|
|
||||||
type processCollector struct {
|
type processCollector struct {
|
||||||
@@ -77,6 +79,11 @@ func newProcessCollectorFlags(app *kingpin.Application) {
|
|||||||
return nil
|
return nil
|
||||||
}).String()
|
}).String()
|
||||||
|
|
||||||
|
enableWorkerProcess = kingpin.Flag(
|
||||||
|
"collector.process.iis",
|
||||||
|
"Enable IIS worker process name queries. May cause the collector to leak memory.",
|
||||||
|
).Default("false").Bool()
|
||||||
|
|
||||||
processOldInclude = app.Flag(
|
processOldInclude = app.Flag(
|
||||||
FlagProcessOldInclude,
|
FlagProcessOldInclude,
|
||||||
"DEPRECATED: Use --collector.process.include",
|
"DEPRECATED: Use --collector.process.include",
|
||||||
@@ -255,9 +262,11 @@ func (c *processCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dst_wp []WorkerProcess
|
var dst_wp []WorkerProcess
|
||||||
q_wp := queryAll(&dst_wp, c.logger)
|
if *enableWorkerProcess {
|
||||||
if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
|
q_wp := queryAll(&dst_wp, c.logger)
|
||||||
_ = level.Debug(c.logger).Log("msg", fmt.Sprintf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping", err))
|
if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
|
||||||
|
_ = level.Debug(c.logger).Log(fmt.Sprintf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping\n", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, process := range data {
|
for _, process := range data {
|
||||||
@@ -271,10 +280,12 @@ func (c *processCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr
|
|||||||
pid := strconv.FormatUint(uint64(process.IDProcess), 10)
|
pid := strconv.FormatUint(uint64(process.IDProcess), 10)
|
||||||
cpid := strconv.FormatUint(uint64(process.CreatingProcessID), 10)
|
cpid := strconv.FormatUint(uint64(process.CreatingProcessID), 10)
|
||||||
|
|
||||||
for _, wp := range dst_wp {
|
if *enableWorkerProcess {
|
||||||
if wp.ProcessId == uint64(process.IDProcess) {
|
for _, wp := range dst_wp {
|
||||||
processName = strings.Join([]string{processName, wp.AppPoolName}, "_")
|
if wp.ProcessId == uint64(process.IDProcess) {
|
||||||
break
|
processName = strings.Join([]string{processName, wp.AppPoolName}, "_")
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ Enabled by default? | No
|
|||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
### `--collector.process.include`
|
### `--collector.process.include`
|
||||||
|
|
||||||
Regexp of processes to include. Process name must both match `include` and not
|
Regexp of processes to include. Process name must both match `include` and not
|
||||||
@@ -23,6 +24,12 @@ Regexp of processes to exclude. Process name must both match `include` and not
|
|||||||
match `exclude` to be included. Recommended to keep down number of returned
|
match `exclude` to be included. Recommended to keep down number of returned
|
||||||
metrics.
|
metrics.
|
||||||
|
|
||||||
|
### `--collector.process.iis`
|
||||||
|
|
||||||
|
Enables IIS process name queries. IIS process names are combined with their app pool name to form the `process` label.
|
||||||
|
|
||||||
|
Disabled by default, and can be enabled with `--collector.process.iis=true`.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
To match all firefox processes: `--collector.process.include="firefox.*"`.
|
To match all firefox processes: `--collector.process.include="firefox.*"`.
|
||||||
Note that multiple processes with the same name will be disambiguated by
|
Note that multiple processes with the same name will be disambiguated by
|
||||||
|
|||||||
Reference in New Issue
Block a user