-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Processor & Aggregator Plugins
closes #1726
- Loading branch information
Showing
14 changed files
with
409 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package telegraf | ||
|
||
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 Metric) | ||
|
||
// Start starts the service filter with the given accumulator | ||
Start(acc Accumulator) | ||
Stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package models | ||
|
||
import ( | ||
"github.com/influxdata/telegraf" | ||
) | ||
|
||
type RunningProcessor struct { | ||
Name string | ||
Processor telegraf.Processor | ||
Config *ProcessorConfig | ||
} | ||
|
||
// FilterConfig containing a name and filter | ||
type ProcessorConfig struct { | ||
Name string | ||
Filter Filter | ||
} | ||
|
||
func (rf *RunningProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric { | ||
ret := []telegraf.Metric{} | ||
|
||
for _, metric := range in { | ||
if rf.Config.Filter.IsActive() { | ||
// check if the filter should be applied to this metric | ||
if ok := rf.Config.Filter.Apply(metric.Name(), metric.Fields(), metric.Tags()); !ok { | ||
// this means filter should not be applied | ||
ret = append(ret, metric) | ||
continue | ||
} | ||
} | ||
// This metric should pass through the filter, so call the filter Apply | ||
// function and append results to the output slice. | ||
ret = append(ret, rf.Processor.Apply(metric)...) | ||
} | ||
|
||
return ret | ||
} |
Oops, something went wrong.