-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
EDIT: the proposed Aggregator interface has changed, see #1726 (comment)
Proposal:
processor & aggregator plugins will be new types of plugins that sit in-between input and output plugins.
If there are processors or aggregators defined in the config, then all metrics will pass through them before being passed onto the output plugins.
processor plugins will generically support matching based on (with globbing):
- tag key/value
- measurement name
- field keys
aggregator plugins will generically support matching based on (with globbing):
- tag key/value
- measurement name
- field keys
An initial implementation has been written by @alimousazy in this PR: #1364, but I would like to consider here the structure & interface of processor plugins independent of the histogram/aggregator feature.
My proposal for the processor interface differs a bit from that PR. While that PR presents an interesting way of streaming metrics through multiple channels, it also raises an important question of how large to create each channel, which could greatly increase the total possible buffer size of telegraf.
Channels are great for multiple processes to run concurrently and aggregate their work in one place, but this is not actually the workflow of a processor plugin. For each metric that comes from the input plugins, each processor will need to be applied, and after all processors are applied the metric(s) will be passed onto the aggregator plugin(s) & output plugin(s).
The original metric will therefore get sent directly to the output plugins, while the aggregator plugins are free to process the metric as they need, adding their metrics to their accumulator as they need.
type Processor interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
// Description returns a one-sentence description on the Input
Description() string
// Apply the processor to the given metric
Apply(in ...telegraf.Metric) []telegraf.Metric
}
type Aggregator interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
// Description returns a one-sentence description on the Input
Description() string
// Apply the metric to the aggregator
Apply(in telegraf.Metric)
// Start starts the aggregator
Start(acc telegraf.Accumulator)
Stop()
}Use case: [Why is this important (helps with prioritizing requests)]
some of the uses of these plugins:
- dropping metrics
- aggregating metrics
- adding & removing tags
- adding & removing fields
- modifying fields, measurement names, tags, etc.
Open Questions:
- Ordering: how do we deal with ordering of processors? do we need to support an argument for users to manually order the plugins? or can we rely on the configuration file to provide the order for us?
- Allocations: what affect are processor plugins going to have on allocations?