Skip to content

Commit

Permalink
fix: Update prometheusremotewrite parser to be a new style parser plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
reimda committed Jul 5, 2022
1 parent 2f67010 commit 980c82f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions plugins/parsers/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/parsers/json_v2"
_ "github.com/influxdata/telegraf/plugins/parsers/logfmt"
_ "github.com/influxdata/telegraf/plugins/parsers/nagios"
_ "github.com/influxdata/telegraf/plugins/parsers/prometheusremotewrite"
_ "github.com/influxdata/telegraf/plugins/parsers/value"
_ "github.com/influxdata/telegraf/plugins/parsers/wavefront"
_ "github.com/influxdata/telegraf/plugins/parsers/xpath"
Expand Down
12 changes: 12 additions & 0 deletions plugins/parsers/prometheusremotewrite/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/influxdata/telegraf/plugins/parsers"

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/prompb"
Expand Down Expand Up @@ -82,3 +83,14 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
func (p *Parser) SetDefaultTags(tags map[string]string) {
p.DefaultTags = tags
}

func (p *Parser) InitFromConfig(config *parsers.Config) error {
return nil
}

func init() {
parsers.Add("prometheusremotewrite",
func(defaultMetricName string) telegraf.Parser {
return &Parser{}
})
}
9 changes: 0 additions & 9 deletions plugins/parsers/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/influxdata/telegraf/plugins/parsers/influx"
"github.com/influxdata/telegraf/plugins/parsers/influx/influx_upstream"
"github.com/influxdata/telegraf/plugins/parsers/prometheus"
"github.com/influxdata/telegraf/plugins/parsers/prometheusremotewrite"
"github.com/influxdata/telegraf/plugins/parsers/temporary/json_v2"
"github.com/influxdata/telegraf/plugins/parsers/temporary/xpath"
)
Expand Down Expand Up @@ -207,8 +206,6 @@ func NewParser(config *Config) (Parser, error) {
config.DefaultTags,
config.PrometheusIgnoreTimestamp,
)
case "prometheusremotewrite":
parser, err = NewPrometheusRemoteWriteParser(config.DefaultTags)
default:
creator, found := Parsers[config.DataFormat]
if !found {
Expand Down Expand Up @@ -242,9 +239,3 @@ func NewPrometheusParser(defaultTags map[string]string, ignoreTimestamp bool) (P
IgnoreTimestamp: ignoreTimestamp,
}, nil
}

func NewPrometheusRemoteWriteParser(defaultTags map[string]string) (Parser, error) {
return &prometheusremotewrite.Parser{
DefaultTags: defaultTags,
}, nil
}

0 comments on commit 980c82f

Please sign in to comment.