forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 2
/
printer.go
44 lines (36 loc) · 851 Bytes
/
printer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package printer
import (
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/processors"
"github.com/influxdata/telegraf/plugins/serializers"
"github.com/influxdata/telegraf/plugins/serializers/influx"
)
type Printer struct {
serializer serializers.Serializer
}
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 {
octets, err := p.serializer.Serialize(metric)
if err != nil {
continue
}
fmt.Printf("%s", octets)
}
return in
}
func init() {
processors.Add("printer", func() telegraf.Processor {
return &Printer{
serializer: influx.NewSerializer(),
}
})
}