Skip to content

Commit

Permalink
Change pass/drop to namepass/namedrop for outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc authored and geodimm committed Mar 10, 2016
1 parent 5d35809 commit e096694
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,22 @@ configuring each output sink is different, but examples can be
found by running `telegraf -sample-config`.

Outputs also support the same configurable options as inputs
(pass, drop, tagpass, tagdrop)
(namepass, namedrop, tagpass, tagdrop)

```toml
[[outputs.influxdb]]
urls = [ "http://localhost:8086" ]
database = "telegraf"
precision = "s"
# Drop all measurements that start with "aerospike"
drop = ["aerospike*"]
namedrop = ["aerospike*"]

[[outputs.influxdb]]
urls = [ "http://localhost:8086" ]
database = "telegraf-aerospike-data"
precision = "s"
# Only accept aerospike data:
pass = ["aerospike*"]
namepass = ["aerospike*"]

[[outputs.influxdb]]
urls = [ "http://localhost:8086" ]
Expand Down
2 changes: 1 addition & 1 deletion etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
# Whether to report total system cpu stats or not
totalcpu = true
# Comment this line if you want the raw CPU time metrics
drop = ["time_*"]
fielddrop = ["time_*"]

# Read metrics about disk usage by mount point
[[inputs.disk]]
Expand Down
10 changes: 9 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ func (c *Config) addInput(name string, table *ast.Table) error {
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
// filtering on tags and measurements
func buildFilter(tbl *ast.Table) internal_models.Filter {
Expand Down Expand Up @@ -752,5 +753,12 @@ func buildOutput(name string, tbl *ast.Table) (*internal_models.OutputConfig, er
Name: name,
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
}
2 changes: 1 addition & 1 deletion internal/models/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Filter struct {
}

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 false
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/system/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var sampleConfig = `
## Whether to report total system cpu stats or not
totalcpu = true
## Comment this line if you want the raw CPU time metrics
drop = ["time_*"]
fielddrop = ["time_*"]
`

func (_ *CPUStats) SampleConfig() string {
Expand Down

0 comments on commit e096694

Please sign in to comment.