Implement Glob matching for pass/drop filters

This commit is contained in:
Cameron Sparr
2015-12-07 15:37:05 -07:00
parent 22afc99f1e
commit 03e66d5b87
7 changed files with 299 additions and 17 deletions

View File

@@ -94,13 +94,12 @@ InfluxDB.
There are 5 configuration options that are configurable per plugin:
* **pass**: An array of strings that is used to filter metrics generated by the
current plugin. Each string in the array is tested as a prefix against metric names
current plugin. Each string in the array is tested as a glob match against metric names
and if it matches, the metric is emitted.
* **drop**: The inverse of pass, if a metric name matches, it is not emitted.
* **tagpass**: (added in 0.1.5) tag names and arrays of strings that are used to filter metrics by
the current plugin. Each string in the array is tested as an exact match against
* **tagpass**: tag names and arrays of strings that are used to filter metrics by the current plugin. Each string in the array is tested as a glob match against
the tag name, and if it matches the metric is emitted.
* **tagdrop**: (added in 0.1.5) The inverse of tagpass. If a tag matches, the metric is not emitted.
* **tagdrop**: The inverse of tagpass. If a tag matches, the metric is not emitted.
This is tested on metrics that have passed the tagpass test.
* **interval**: How often to gather this metric. Normal plugins use a single
global interval, but if one particular plugin should be run less or more often,
@@ -132,10 +131,10 @@ measurements which begin with `cpu_time`.
[[plugins.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
drop = ["cpu_time*"]
```
Below is how to configure `tagpass` and `tagdrop` parameters (added in 0.1.5)
Below is how to configure `tagpass` and `tagdrop` parameters
```toml
[plugins]
@@ -153,10 +152,11 @@ Below is how to configure `tagpass` and `tagdrop` parameters (added in 0.1.5)
# If the (filesystem is ext4 or xfs) OR (the path is /opt or /home)
# then the metric passes
fstype = [ "ext4", "xfs" ]
path = [ "/opt", "/home" ]
# Globs can also be used on the tag values
path = [ "/opt", "/home*" ]
```
Below is how to configure `pass` and `drop` parameters (added in 0.1.5)
Below is how to configure `pass` and `drop` parameters
```toml
# Drop all metrics for guest CPU usage
@@ -165,17 +165,22 @@ Below is how to configure `pass` and `drop` parameters (added in 0.1.5)
# Only store inode related metrics for disks
[[plugins.disk]]
pass = [ "disk_inodes" ]
pass = [ "disk_inodes*" ]
```
Additional plugins (or outputs) of the same type can be specified,
just define another instance in the config file:
just define more instances in the config file:
```toml
[[plugins.cpu]]
percpu = false
totalcpu = true
[[plugins.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time*"]
```
## Supported Plugins
@@ -246,14 +251,14 @@ Outputs also support the same configurable options as plugins (pass, drop, tagpa
database = "telegraf"
precision = "s"
# Drop all measurements that start with "aerospike"
drop = ["aerospike"]
drop = ["aerospike*"]
[[outputs.influxdb]]
urls = [ "http://localhost:8086" ]
database = "telegraf-aerospike-data"
precision = "s"
# Only accept aerospike data:
pass = ["aerospike"]
pass = ["aerospike*"]
[[outputs.influxdb]]
urls = [ "http://localhost:8086" ]