2016-09-08 14:22:10 +00:00
|
|
|
package printer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/influxdata/telegraf"
|
|
|
|
"github.com/influxdata/telegraf/plugins/processors"
|
2018-03-28 00:30:51 +00:00
|
|
|
"github.com/influxdata/telegraf/plugins/serializers"
|
|
|
|
"github.com/influxdata/telegraf/plugins/serializers/influx"
|
2016-09-08 14:22:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Printer struct {
|
2018-03-28 00:30:51 +00:00
|
|
|
serializer serializers.Serializer
|
2016-09-08 14:22:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var sampleConfig = `
|
|
|
|
`
|
|
|
|
|
|
|
|
func (p *Printer) SampleConfig() string {
|
|
|
|
return sampleConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Printer) Description() string {
|
|
|
|
return "Print all metrics that pass through this filter."
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Printer) Apply(in ...telegraf.Metric) []telegraf.Metric {
|
|
|
|
for _, metric := range in {
|
2018-03-28 00:30:51 +00:00
|
|
|
octets, err := p.serializer.Serialize(metric)
|
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
fmt.Println(octets)
|
2016-09-08 14:22:10 +00:00
|
|
|
}
|
|
|
|
return in
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
processors.Add("printer", func() telegraf.Processor {
|
2018-03-28 00:30:51 +00:00
|
|
|
return &Printer{
|
|
|
|
serializer: influx.NewSerializer(),
|
|
|
|
}
|
2016-09-08 14:22:10 +00:00
|
|
|
})
|
|
|
|
}
|