Change pass/drop to namepass/namedrop for outputs

closes #730
This commit is contained in:
Cameron Sparr 2016-02-22 13:35:06 -07:00
parent d00550c45f
commit 5aef725c13
5 changed files with 15 additions and 7 deletions

View File

@ -209,7 +209,7 @@ configuring each output sink is different, but examples can be
found by running `telegraf -sample-config`. found by running `telegraf -sample-config`.
Outputs also support the same configurable options as inputs Outputs also support the same configurable options as inputs
(pass, drop, tagpass, tagdrop) (namepass, namedrop, tagpass, tagdrop)
```toml ```toml
[[outputs.influxdb]] [[outputs.influxdb]]
@ -217,14 +217,14 @@ Outputs also support the same configurable options as inputs
database = "telegraf" database = "telegraf"
precision = "s" precision = "s"
# Drop all measurements that start with "aerospike" # Drop all measurements that start with "aerospike"
drop = ["aerospike*"] namedrop = ["aerospike*"]
[[outputs.influxdb]] [[outputs.influxdb]]
urls = [ "http://localhost:8086" ] urls = [ "http://localhost:8086" ]
database = "telegraf-aerospike-data" database = "telegraf-aerospike-data"
precision = "s" precision = "s"
# Only accept aerospike data: # Only accept aerospike data:
pass = ["aerospike*"] namepass = ["aerospike*"]
[[outputs.influxdb]] [[outputs.influxdb]]
urls = [ "http://localhost:8086" ] urls = [ "http://localhost:8086" ]

View File

@ -89,7 +89,7 @@
# Whether to report total system cpu stats or not # Whether to report total system cpu stats or not
totalcpu = true totalcpu = true
# Comment this line if you want the raw CPU time metrics # Comment this line if you want the raw CPU time metrics
drop = ["time_*"] fielddrop = ["time_*"]
# Read metrics about disk usage by mount point # Read metrics about disk usage by mount point
[[inputs.disk]] [[inputs.disk]]

View File

@ -477,7 +477,8 @@ func (c *Config) addInput(name string, table *ast.Table) error {
return nil return nil
} }
// buildFilter builds a Filter (tagpass/tagdrop/pass/drop) to // buildFilter builds a Filter
// (tagpass/tagdrop/namepass/namedrop/fieldpass/fielddrop) to
// be inserted into the internal_models.OutputConfig/internal_models.InputConfig to be used for prefix // be inserted into the internal_models.OutputConfig/internal_models.InputConfig to be used for prefix
// filtering on tags and measurements // filtering on tags and measurements
func buildFilter(tbl *ast.Table) internal_models.Filter { func buildFilter(tbl *ast.Table) internal_models.Filter {
@ -752,5 +753,12 @@ func buildOutput(name string, tbl *ast.Table) (*internal_models.OutputConfig, er
Name: name, Name: name,
Filter: buildFilter(tbl), Filter: buildFilter(tbl),
} }
// Outputs don't support FieldDrop/FieldPass, so set to NameDrop/NamePass
if len(oc.Filter.FieldDrop) > 0 {
oc.Filter.NameDrop = oc.Filter.FieldDrop
}
if len(oc.Filter.FieldPass) > 0 {
oc.Filter.NamePass = oc.Filter.FieldPass
}
return oc, nil return oc, nil
} }

View File

@ -28,7 +28,7 @@ type Filter struct {
} }
func (f Filter) ShouldMetricPass(metric telegraf.Metric) bool { func (f Filter) ShouldMetricPass(metric telegraf.Metric) bool {
if f.ShouldFieldsPass(metric.Name()) && f.ShouldTagsPass(metric.Tags()) { if f.ShouldNamePass(metric.Name()) && f.ShouldTagsPass(metric.Tags()) {
return true return true
} }
return false return false

View File

@ -33,7 +33,7 @@ var sampleConfig = `
## Whether to report total system cpu stats or not ## Whether to report total system cpu stats or not
totalcpu = true totalcpu = true
## Comment this line if you want the raw CPU time metrics ## Comment this line if you want the raw CPU time metrics
drop = ["time_*"] fielddrop = ["time_*"]
` `
func (_ *CPUStats) SampleConfig() string { func (_ *CPUStats) SampleConfig() string {