Add collect[] parameter (#699)

* Add `collect[]` parameter

* Add TODo comment about staticcheck ignored

* Restore promhttp.HandlerOpts

* Log a warning and return HTTP error instead of failing

* Check collector existence and status, cleanups

* Fix warnings and error messages

* Don't panic, return error if collector registration failed

* Update README
This commit is contained in:
Siavash Safi 2017-10-14 14:23:42 +02:00 committed by Ben Kochie
commit f3a7022602
4 changed files with 91 additions and 14 deletions

View file

@ -107,6 +107,39 @@ echo 'role{role="application_server"} 1' > /path/to/directory/role.prom.$$
mv /path/to/directory/role.prom.$$ /path/to/directory/role.prom
```
### Filtering enabled collectors
The node_exporter will expose all metrics from enabled collectors by default, but it can be passed an optional list of collectors to filter metrics. The `collect[]` parameter accepts values matching enabled collector names.
This can be useful for specifying different scrape intervals for different collectors in Prometheus:
```yaml
scrape_configs:
- job_name: 'node resources'
scrape_interval: 15s
static_configs:
- targets:
- '192.168.1.2:9100'
params:
collect[]:
- cpu
- meminfo
- diskstats
- netdev
- netstat
- job_name: 'node storage'
scrape_interval: 1m
static_configs:
- targets:
- '192.168.1.2:9100'
params:
collect[]:
- filefd
- filesystem
- xfs
```
## Building and running
Prerequisites: