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

Statsd listener plugin #237

Merged
merged 6 commits into from
Oct 15, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ of metrics collected and from how many plugins.
- [#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!
- [#237](https://github.com/influxdb/telegraf/pull/237): statsd service plugin, thanks @sparrc

### Bugfixes
- [#228](https://github.com/influxdb/telegraf/pull/228): New version of package will replace old one. Thanks @ekini!
Expand Down
108 changes: 103 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ which can be found [on our website](http://influxdb.com/community/cla.html)

## Plugins

This section is for developers that want to create new collection plugins.
This section is for developers who want to create new collection plugins.
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.
Expand All @@ -16,8 +16,6 @@ and submit new plugins.
### Plugin Guidelines

* A plugin must conform to the `plugins.Plugin` interface.
* Telegraf promises to run each plugin's Gather function serially. This means
developers don't have to worry about thread safety within these functions.
* 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.
Expand Down Expand Up @@ -89,7 +87,7 @@ func Gather(acc plugins.Accumulator) error {
}
```

### Example
### Plugin Example

```go
package simple
Expand Down Expand Up @@ -125,9 +123,109 @@ func init() {
}
```

## 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
a background service while Telegraf is running. One example would be the `statsd`
plugin, which operates a statsd server.

Service Plugins are substantially more complicated than a regular plugin, as they
will require threads and locks to verify data integrity. Service Plugins should
be avoided unless there is no way to create their behavior with a regular plugin.

Their interface is quite similar to a regular plugin, with the addition of `Start()`
and `Stop()` methods.

### Service Plugin Guidelines

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

### Service Plugin interface

```go
type ServicePlugin interface {
SampleConfig() string
Description() string
Gather(Accumulator) error
Start() error
Stop()
}
```

## Outputs

TODO: this section will describe requirements for contributing an output
This section is for developers who want to create a new output sink. Outputs
are created in a similar manner as collection plugins, and their interface has
similar constructs.

### Output Guidelines

* An output must conform to the `outputs.Output` interface.
* 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.
* 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.

### Output interface

```go
type Output interface {
Connect() error
Close() error
Description() string
SampleConfig() string
Write(client.BatchPoints) error
}
```

### Output Example

```go
package simpleoutput

// simpleoutput.go

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

type Simple struct {
Ok bool
}

func (s *Simple) Description() string {
return "a demo output"
}

func (s *Simple) SampleConfig() string {
return "url = localhost"
}

func (s *Simple) Connect() error {
// Make a connection to the URL here
return nil
}

func (s *Simple) Close() error {
// Close connection to the URL here
return nil
}

func (s *Simple) Write(bp client.BatchPoints) error {
for _, pt := range bp {
// write `pt` to the output sink here
}
return nil
}

func init() {
outputs.Add("simpleoutput", func() outputs.Output { return &Simple{} })
}

```

## Unit Tests

Expand Down
35 changes: 7 additions & 28 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions Godeps/_workspace/src/github.com/influxdb/influxdb/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading