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 25, 2015
1 parent 9bb2ddd commit 1f9d65e
Show file tree
Hide file tree
Showing 23 changed files with 563 additions and 757 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ This only affects the kafka consumer _plugin_ (not the
output). There were a number of problems with the kafka plugin that led to it
only collecting data once at startup, so the kafka plugin was basically non-
functional.
- Plugins can now be specified as a list, and multiple plugin instances of the
same type can be specified, like this:

```
[[plugins.cpu]]
percpu = false
totalcpu = true
[[plugins.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
```

- Riemann output added

### Features
- [#379](https://github.com/influxdb/telegraf/pull/379): Riemann output, thanks @allenj!
- [#375](https://github.com/influxdb/telegraf/pull/375): kafka_consumer service plugin.
- [#383](https://github.com/influxdb/telegraf/pull/383): Specify plugins as a list.

### Bugfixes
- [#371](https://github.com/influxdb/telegraf/issues/371): Kafka consumer plugin not functioning.
- [#389](https://github.com/influxdb/telegraf/issues/389): NaN value panic

## v0.2.2 [2015-11-18]

Expand Down
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 1f9d65e

Please sign in to comment.