Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change plugin config to be specified as a list #383

Merged
merged 5 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,31 @@ 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.
- [#392](https://github.com/influxdb/telegraf/pull/392): Procstat plugin can now accept pgrep -f pattern, thanks @ecarreras!
- [#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 @@ -7,6 +7,8 @@ import (
"sync"
"time"

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

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

Expand All @@ -27,12 +29,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 @@ -45,7 +47,7 @@ type accumulator struct {

debug bool

plugin *ConfiguredPlugin
pluginConfig *config.PluginConfig

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

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