docs(aggregators): Clean up aggregator docs (#15357)

This commit is contained in:
Joshua Powers 2024-05-16 01:43:05 -06:00 committed by GitHub
parent 73be345d88
commit 8a93207967
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 23 deletions

View File

@ -11,19 +11,42 @@ This section is for developers who want to create a new aggregator plugin.
using a file in `github.com/influxdata/telegraf/plugins/aggregators/all` using a file in `github.com/influxdata/telegraf/plugins/aggregators/all`
named according to the plugin name. Make sure you also add build-tags to named according to the plugin name. Make sure you also add build-tags to
conditionally build the plugin. conditionally build the plugin.
* Each plugin requires a file called `sample.conf` containing the sample configuration * Each plugin requires a file called `sample.conf` containing the sample
for the plugin in TOML format. configuration for the plugin in TOML format. Please consult the
Please consult the [Sample Config][] page for the latest style guidelines. [Sample Config][] page for the latest style guidelines.
* Each plugin `README.md` file should include the `sample.conf` file in a section * Each plugin `README.md` file should include the `sample.conf` file in a
describing the configuration by specifying a `toml` section in the form `toml @sample.conf`. The specified file(s) are then injected automatically into the Readme. section describing the configuration by specifying a `toml` section in the
form `toml @sample.conf`. The specified file(s) are then injected
automatically into the Readme.
* The Aggregator plugin will need to keep caches of metrics that have passed * The Aggregator plugin will need to keep caches of metrics that have passed
through it. This should be done using the builtin `HashID()` function of through it. This should be done using the builtin `HashID()` function of
each metric. each metric.
* When the `Reset()` function is called, all caches should be cleared. * When the `Reset()` function is called, all caches should be cleared.
* Follow the recommended [Code Style][]. * Follow the recommended [Code Style][].
[telegraf.Aggregator]: https://godoc.org/github.com/influxdata/telegraf#Aggregator
[Sample Config]: /docs/developers/SAMPLE_CONFIG.md
[Code Style]: /docs/developers/CODE_STYLE.md
### Aggregator Plugin Example ### Aggregator Plugin Example
### Registration
Registration of the plugin on `plugins/aggregators/all/min.go`:
```go
//go:build !custom || aggregators || aggregators.min
package all
import _ "github.com/influxdata/telegraf/plugins/aggregators/min" // register plugin
```
The _build-tags_ in the first line allow to selectively include/exclude your
plugin when customizing Telegraf.
### Plugin
Content of your plugin file e.g. `min.go` Content of your plugin file e.g. `min.go`
```go ```go
@ -125,21 +148,3 @@ func init() {
}) })
} }
``` ```
Registration of the plugin on `plugins/aggregators/all/min.go`:
```go
//go:build !custom || aggregators || aggregators.min
package all
import _ "github.com/influxdata/telegraf/plugins/aggregators/min" // register plugin
```
The _build-tags_ in the first line allow to selectively include/exclude your
plugin when customizing Telegraf.
[Sample Config]: https://github.com/influxdata/telegraf/blob/master/docs/developers/SAMPLE_CONFIG.md
[Code Style]: https://github.com/influxdata/telegraf/blob/master/docs/developers/CODE_STYLE.md
[telegraf.Aggregator]: https://godoc.org/github.com/influxdata/telegraf#Aggregator