feat!: Disable IIS queries in process collector

IIS queries are disabled by default, and can be enabled with the
`--collector.process.iis=true` flag.

These WMI queries are suspected to be one source of virtual memory leaks
in the exporter.

These WMI queries are also responsible for timeouts on some hosts.

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy 2022-05-29 11:00:37 +10:00
parent 5e7462a70e
commit 6832fd7fd7
No known key found for this signature in database
GPG Key ID: 235C15B6086C9D7E
2 changed files with 25 additions and 7 deletions

View File

@ -34,6 +34,8 @@ var (
processIncludeSet bool
processExcludeSet bool
enableWorkerProcess *bool
)
type processCollector struct {
@ -77,6 +79,11 @@ func newProcessCollectorFlags(app *kingpin.Application) {
return nil
}).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(
FlagProcessOldInclude,
"DEPRECATED: Use --collector.process.include",
@ -255,9 +262,11 @@ func (c *processCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr
}
var dst_wp []WorkerProcess
if *enableWorkerProcess {
q_wp := queryAll(&dst_wp, c.logger)
if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
_ = level.Debug(c.logger).Log("msg", fmt.Sprintf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping", err))
_ = level.Debug(c.logger).Log(fmt.Sprintf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping\n", err))
}
}
for _, process := range data {
@ -271,12 +280,14 @@ func (c *processCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr
pid := strconv.FormatUint(uint64(process.IDProcess), 10)
cpid := strconv.FormatUint(uint64(process.CreatingProcessID), 10)
if *enableWorkerProcess {
for _, wp := range dst_wp {
if wp.ProcessId == uint64(process.IDProcess) {
processName = strings.Join([]string{processName, wp.AppPoolName}, "_")
break
}
}
}
ch <- prometheus.MustNewConstMetric(
c.StartTime,

View File

@ -11,6 +11,7 @@ Enabled by default? | No
## Flags
<<<<<<< HEAD
### `--collector.process.include`
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
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
To match all firefox processes: `--collector.process.include="firefox.*"`.
Note that multiple processes with the same name will be disambiguated by