Skip to content

Commit

Permalink
Overhaul config <-> agent coupling. Put config in it's own package.
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Nov 24, 2015
1 parent 9bb2ddd commit 4125523
Show file tree
Hide file tree
Showing 22 changed files with 547 additions and 757 deletions.
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,44 +110,61 @@ you can configure that here.

This is a full working config that will output CPU data to an InfluxDB instance
at 192.168.59.103:8086, tagging measurements with dc="denver-1". It will output
measurements at a 10s interval and will collect totalcpu & percpu data.
measurements at a 10s interval and will collect per-cpu data, dropping any
measurements which begin with `cpu_time`.

```
[tags]
dc = "denver-1"
dc = "denver-1"
[agent]
interval = "10s"
interval = "10s"
# OUTPUTS
[outputs]
[[outputs.influxdb]]
url = "http://192.168.59.103:8086" # required.
database = "telegraf" # required.
precision = "s"
url = "http://192.168.59.103:8086" # required.
database = "telegraf" # required.
precision = "s"
# PLUGINS
[cpu]
percpu = true
totalcpu = true
[plugins]
[[plugins.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
```

Below is how to configure `tagpass` and `tagdrop` parameters (added in 0.1.5)

```
# Don't collect CPU data for cpu6 & cpu7
[cpu.tagdrop]
[plugins]
[[plugins.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
# Don't collect CPU data for cpu6 & cpu7
[plugins.cpu.tagdrop]
cpu = [ "cpu6", "cpu7" ]
[disk]
[disk.tagpass]
[[plugins.disk]]
[plugins.disk.tagpass]
# tagpass conditions are OR, not AND.
# If the (filesystem is ext4 or xfs) OR (the path is /opt or /home)
# then the metric passes
fstype = [ "ext4", "xfs" ]
path = [ "/opt", "/home" ]
```

Additional plugins (or outputs) of the same type can be specified,
just define another instance in the config file:

```
[[plugins.cpu]]
percpu = false
totalcpu = true
```

## Supported Plugins

**You can view usage instructions for each plugin by running**
Expand Down
12 changes: 7 additions & 5 deletions accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"sync"
"time"

"github.com/influxdb/telegraf/internal/config"

"github.com/influxdb/influxdb/client/v2"
)

Expand All @@ -26,12 +28,12 @@ type Accumulator interface {
}

func NewAccumulator(
plugin *ConfiguredPlugin,
pluginConfig *config.PluginConfig,
points chan *client.Point,
) Accumulator {
acc := accumulator{}
acc.points = points
acc.plugin = plugin
acc.pluginConfig = pluginConfig
return &acc
}

Expand All @@ -44,7 +46,7 @@ type accumulator struct {

debug bool

plugin *ConfiguredPlugin
pluginConfig *config.PluginConfig

prefix string
}
Expand Down Expand Up @@ -96,8 +98,8 @@ func (ac *accumulator) AddFields(
measurement = ac.prefix + measurement
}

if ac.plugin != nil {
if !ac.plugin.ShouldPass(measurement) || !ac.plugin.ShouldTagsPass(tags) {
if ac.pluginConfig != nil {
if !ac.pluginConfig.ShouldPass(measurement) || !ac.pluginConfig.ShouldTagsPass(tags) {
return
}
}
Expand Down
Loading

0 comments on commit 4125523

Please sign in to comment.