Skip to content

Commit

Permalink
renaming plugins -> inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Jan 7, 2016
1 parent 30d24a3 commit 9c5db10
Show file tree
Hide file tree
Showing 175 changed files with 595 additions and 561 deletions.
23 changes: 13 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
## v0.3.0 [unreleased]

### Release Notes
- **breaking change** `plugins` have been renamed to `inputs`. This was done because
`plugins` is too generic, as there are now also "output plugins", and will likely
be "aggregator plugins" and "filter plugins" in the future. Additionally,
`inputs/` and `outputs/` directories have been placed in the root-level `plugins/`
directory.
- **breaking change** the `io` plugin has been renamed `diskio`
- **breaking change** Plugin measurements aggregated into a single measurement.
- **breaking change** `jolokia` plugin: must use global tag/drop/pass parameters
for configuration.
- **breaking change** `procstat` plugin has `*cpu*` fields renamed to
`*cpu_time*`
- `twemproxy` plugin: `prefix` option removed.
- `procstat` cpu measurements are now prepended with `cpu_time_` instead of
- **breaking change** `twemproxy` plugin: `prefix` option removed.
- **breaking change** `procstat` cpu measurements are now prepended with `cpu_time_` instead of
only `cpu_`
- The prometheus plugin schema has not been changed (measurements have not been
aggregated).
Expand All @@ -18,7 +21,7 @@ aggregated).
- Added ability to specify per-plugin tags
- Added ability to specify per-plugin measurement suffix and prefix.
(`name_prefix` and `name_suffix`)
- Added ability to override base plugin name. (`name_override`)
- Added ability to override base plugin measurement name. (`name_override`)

### Bugfixes

Expand Down Expand Up @@ -62,11 +65,11 @@ functional.
same type can be specified, like this:

```
[[plugins.cpu]]
[[inputs.cpu]]
percpu = false
totalcpu = true
[[plugins.cpu]]
[[inputs.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
Expand All @@ -93,7 +96,7 @@ same type can be specified, like this:
lists of servers/URLs. 0.2.2 is being released solely to fix that bug

### Bugfixes
- [#377](https://github.com/influxdb/telegraf/pull/377): Fix for duplicate slices in plugins.
- [#377](https://github.com/influxdb/telegraf/pull/377): Fix for duplicate slices in inputs.

## v0.2.1 [2015-11-16]

Expand Down Expand Up @@ -154,7 +157,7 @@ be controlled via the `round_interval` and `flush_jitter` config options.
- [#241](https://github.com/influxdb/telegraf/pull/241): MQTT Output. Thanks @shirou!
- Memory plugin: cached and buffered measurements re-added
- Logging: additional logging for each collection interval, track the number
of metrics collected and from how many plugins.
of metrics collected and from how many inputs.
- [#240](https://github.com/influxdb/telegraf/pull/240): procstat plugin, thanks @ranjib!
- [#244](https://github.com/influxdb/telegraf/pull/244): netstat plugin, thanks @shirou!
- [#262](https://github.com/influxdb/telegraf/pull/262): zookeeper plugin, thanks @jrxFive!
Expand Down Expand Up @@ -187,7 +190,7 @@ will still be backwards compatible if only `url` is specified.
- The -test flag will now output two metric collections
- Support for filtering telegraf outputs on the CLI -- Telegraf will now
allow filtering of output sinks on the command-line using the `-outputfilter`
flag, much like how the `-filter` flag works for plugins.
flag, much like how the `-filter` flag works for inputs.
- Support for filtering on config-file creation -- Telegraf now supports
filtering to -sample-config command. You can now run
`telegraf -sample-config -filter cpu -outputfilter influxdb` to get a config
Expand Down
32 changes: 16 additions & 16 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
A default Telegraf config file can be generated using the `-sample-config` flag,
like this: `telegraf -sample-config`

To generate a file with specific collectors and outputs, you can use the
`-filter` and `-outputfilter` flags, like this:
`telegraf -sample-config -filter cpu:mem:net:swap -outputfilter influxdb:kafka`
To generate a file with specific inputs and outputs, you can use the
`-input-filter` and `-output-filter` flags, like this:
`telegraf -sample-config -input-filter cpu:mem:net:swap -output-filter influxdb:kafka`

## Plugin Configuration

Expand Down Expand Up @@ -59,7 +59,7 @@ fields which begin with `time_`.

# PLUGINS
[plugins]
[[plugins.cpu]]
[[inputs.cpu]]
percpu = true
totalcpu = false
# filter all fields beginning with 'time_'
Expand All @@ -70,16 +70,16 @@ fields which begin with `time_`.

```toml
[plugins]
[[plugins.cpu]]
[[inputs.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time"]
# Don't collect CPU data for cpu6 & cpu7
[plugins.cpu.tagdrop]
[inputs.cpu.tagdrop]
cpu = [ "cpu6", "cpu7" ]

[[plugins.disk]]
[plugins.disk.tagpass]
[[inputs.disk]]
[inputs.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
Expand All @@ -92,13 +92,13 @@ fields which begin with `time_`.

```toml
# Drop all metrics for guest & steal CPU usage
[[plugins.cpu]]
[[inputs.cpu]]
percpu = false
totalcpu = true
drop = ["usage_guest", "usage_steal"]

# Only store inode related metrics for disks
[[plugins.disk]]
[[inputs.disk]]
pass = ["inodes*"]
```

Expand All @@ -107,7 +107,7 @@ fields which begin with `time_`.
This plugin will emit measurements with the name `cpu_total`

```toml
[[plugins.cpu]]
[[inputs.cpu]]
name_suffix = "_total"
percpu = false
totalcpu = true
Expand All @@ -116,7 +116,7 @@ This plugin will emit measurements with the name `cpu_total`
This will emit measurements with the name `foobar`

```toml
[[plugins.cpu]]
[[inputs.cpu]]
name_override = "foobar"
percpu = false
totalcpu = true
Expand All @@ -128,10 +128,10 @@ This plugin will emit measurements with two additional tags: `tag1=foo` and
`tag2=bar`

```toml
[[plugins.cpu]]
[[inputs.cpu]]
percpu = false
totalcpu = true
[plugins.cpu.tags]
[inputs.cpu.tags]
tag1 = "foo"
tag2 = "bar"
```
Expand All @@ -142,11 +142,11 @@ Additional plugins (or outputs) of the same type can be specified,
just define more instances in the config file:

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

[[plugins.cpu]]
[[inputs.cpu]]
percpu = true
totalcpu = false
drop = ["cpu_time*"]
Expand Down
28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ which can be found [on our website](http://influxdb.com/community/cla.html)

## Plugins

This section is for developers who want to create new collection plugins.
This section is for developers who want to create new collection inputs.
Telegraf is entirely plugin driven. This interface allows for operators to
pick and chose what is gathered as well as makes it easy for developers
to create new ways of generating metrics.

Plugin authorship is kept as simple as possible to promote people to develop
and submit new plugins.
and submit new inputs.

### Plugin Guidelines

* A plugin must conform to the `plugins.Plugin` interface.
* A plugin must conform to the `inputs.Input` interface.
* Each generated metric automatically has the name of the plugin that generated
it prepended. This is to keep plugins honest.
* Plugins should call `plugins.Add` in their `init` function to register themselves.
* Plugins should call `inputs.Add` in their `init` function to register themselves.
See below for a quick example.
* To be available within Telegraf itself, plugins must add themselves to the
`github.com/influxdb/telegraf/plugins/all/all.go` file.
`github.com/influxdb/telegraf/plugins/inputs/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the
plugin can be configured. This is include in `telegraf -sample-config`.
* The `Description` function should say in one line what this plugin does.
Expand Down Expand Up @@ -78,7 +78,7 @@ type Process struct {
PID int
}

func Gather(acc plugins.Accumulator) error {
func Gather(acc inputs.Accumulator) error {
for _, process := range system.Processes() {
tags := map[string]string {
"pid": fmt.Sprintf("%d", process.Pid),
Expand All @@ -97,7 +97,7 @@ package simple

// simple.go

import "github.com/influxdb/telegraf/plugins"
import "github.com/influxdb/telegraf/plugins/inputs"

type Simple struct {
Ok bool
Expand All @@ -111,7 +111,7 @@ func (s *Simple) SampleConfig() string {
return "ok = true # indicate if everything is fine"
}

func (s *Simple) Gather(acc plugins.Accumulator) error {
func (s *Simple) Gather(acc inputs.Accumulator) error {
if s.Ok {
acc.Add("state", "pretty good", nil)
} else {
Expand All @@ -122,14 +122,14 @@ func (s *Simple) Gather(acc plugins.Accumulator) error {
}

func init() {
plugins.Add("simple", func() plugins.Plugin { return &Simple{} })
inputs.Add("simple", func() inputs.Input { return &Simple{} })
}
```

## Service Plugins

This section is for developers who want to create new "service" collection
plugins. A service plugin differs from a regular plugin in that it operates
inputs. A service plugin differs from a regular plugin in that it operates
a background service while Telegraf is running. One example would be the `statsd`
plugin, which operates a statsd server.

Expand All @@ -143,7 +143,7 @@ and `Stop()` methods.
### Service Plugin Guidelines

* Same as the `Plugin` guidelines, except that they must conform to the
`plugins.ServicePlugin` interface.
`inputs.ServiceInput` interface.

### Service Plugin interface

Expand All @@ -169,7 +169,7 @@ similar constructs.
* Outputs should call `outputs.Add` in their `init` function to register themselves.
See below for a quick example.
* To be available within Telegraf itself, plugins must add themselves to the
`github.com/influxdb/telegraf/outputs/all/all.go` file.
`github.com/influxdb/telegraf/plugins/outputs/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the
output can be configured. This is include in `telegraf -sample-config`.
* The `Description` function should say in one line what this output does.
Expand All @@ -193,7 +193,7 @@ package simpleoutput

// simpleoutput.go

import "github.com/influxdb/telegraf/outputs"
import "github.com/influxdb/telegraf/plugins/outputs"

type Simple struct {
Ok bool
Expand Down Expand Up @@ -243,7 +243,7 @@ and `Stop()` methods.
### Service Output Guidelines

* Same as the `Output` guidelines, except that they must conform to the
`plugins.ServiceOutput` interface.
`inputs.ServiceOutput` interface.

### Service Output interface

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ APIs (like Mailchimp, AWS CloudWatch, or Google Analytics).
We'll eagerly accept pull requests for new plugins and will manage the set of
plugins that Telegraf supports. See the
[contributing guide](CONTRIBUTING.md) for instructions on
writing new plugins.
writing new inputs.

## Installation:

Expand Down Expand Up @@ -92,15 +92,15 @@ if you don't have it already. You also must build with golang version 1.4+.
### How to use it:

* Run `telegraf -sample-config > telegraf.conf` to create an initial configuration.
* Or run `telegraf -sample-config -filter cpu:mem -outputfilter influxdb > telegraf.conf`.
* Or run `telegraf -sample-config -input-filter cpu:mem -output-filter influxdb > telegraf.conf`.
to create a config file with only CPU and memory plugins defined, and InfluxDB
output defined.
* Edit the configuration to match your needs.
* Run `telegraf -config telegraf.conf -test` to output one full measurement
sample to STDOUT. NOTE: you may want to run as the telegraf user if you are using
the linux packages `sudo -u telegraf telegraf -config telegraf.conf -test`
* Run `telegraf -config telegraf.conf` to gather and send metrics to configured outputs.
* Run `telegraf -config telegraf.conf -filter system:swap`.
* Run `telegraf -config telegraf.conf -input-filter system:swap`.
to run telegraf with only the system & swap plugins defined in the config.

## Telegraf Options
Expand Down
26 changes: 13 additions & 13 deletions accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ type Accumulator interface {
}

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

Expand All @@ -47,7 +47,7 @@ type accumulator struct {

debug bool

pluginConfig *config.PluginConfig
inputConfig *config.InputConfig

prefix string
}
Expand All @@ -73,27 +73,27 @@ func (ac *accumulator) AddFields(
return
}

if !ac.pluginConfig.Filter.ShouldTagsPass(tags) {
if !ac.inputConfig.Filter.ShouldTagsPass(tags) {
return
}

// Override measurement name if set
if len(ac.pluginConfig.NameOverride) != 0 {
measurement = ac.pluginConfig.NameOverride
if len(ac.inputConfig.NameOverride) != 0 {
measurement = ac.inputConfig.NameOverride
}
// Apply measurement prefix and suffix if set
if len(ac.pluginConfig.MeasurementPrefix) != 0 {
measurement = ac.pluginConfig.MeasurementPrefix + measurement
if len(ac.inputConfig.MeasurementPrefix) != 0 {
measurement = ac.inputConfig.MeasurementPrefix + measurement
}
if len(ac.pluginConfig.MeasurementSuffix) != 0 {
measurement = measurement + ac.pluginConfig.MeasurementSuffix
if len(ac.inputConfig.MeasurementSuffix) != 0 {
measurement = measurement + ac.inputConfig.MeasurementSuffix
}

if tags == nil {
tags = make(map[string]string)
}
// Apply plugin-wide tags if set
for k, v := range ac.pluginConfig.Tags {
for k, v := range ac.inputConfig.Tags {
if _, ok := tags[k]; !ok {
tags[k] = v
}
Expand All @@ -108,8 +108,8 @@ func (ac *accumulator) AddFields(
result := make(map[string]interface{})
for k, v := range fields {
// Filter out any filtered fields
if ac.pluginConfig != nil {
if !ac.pluginConfig.Filter.ShouldPass(k) {
if ac.inputConfig != nil {
if !ac.inputConfig.Filter.ShouldPass(k) {
continue
}
}
Expand Down
Loading

0 comments on commit 9c5db10

Please sign in to comment.