Removed the Tags capability from the graphite parser.
This commit is contained in:
@@ -44,19 +44,15 @@ and strings will be ignored.
|
||||
### If matching multiple measurement files, this string will be used to join the matched values.
|
||||
#separator = "."
|
||||
|
||||
### Default tags that will be added to all metrics. These can be overridden at the template level
|
||||
### or by tags extracted from metric
|
||||
#tags = ["region=north-east", "zone=1c"]
|
||||
|
||||
### Each template line requires a template pattern. It can have an optional
|
||||
### filter before the template and separated by spaces. It can also have optional extra
|
||||
### tags following the template. Multiple tags should be separated by commas and no spaces
|
||||
### similar to the line protocol format. The can be only one default template.
|
||||
### Templates support below format:
|
||||
### filter + template
|
||||
### filter + template + extra tag
|
||||
### filter + template with field key
|
||||
### default template. Ignore the first graphite component "servers"
|
||||
### 1. filter + template
|
||||
### 2. filter + template + extra tag
|
||||
### 3. filter + template with field key
|
||||
### 4. default template
|
||||
#templates = [
|
||||
# "*.app env.service.resource.measurement",
|
||||
# "stats.* .host.measurement* region=us-west,agent=sensu",
|
||||
@@ -149,19 +145,15 @@ We can also change the data_format to "graphite" to use the metrics collecting s
|
||||
### If matching multiple measurement files, this string will be used to join the matched values.
|
||||
separator = "."
|
||||
|
||||
### Default tags that will be added to all metrics. These can be overridden at the template level
|
||||
### or by tags extracted from metric
|
||||
tags = ["region=north-east", "zone=1c"]
|
||||
|
||||
### Each template line requires a template pattern. It can have an optional
|
||||
### filter before the template and separated by spaces. It can also have optional extra
|
||||
### tags following the template. Multiple tags should be separated by commas and no spaces
|
||||
### similar to the line protocol format. The can be only one default template.
|
||||
### Templates support below format:
|
||||
### filter + template
|
||||
### filter + template + extra tag
|
||||
### filter + template with field key
|
||||
### default template. Ignore the first graphite component "servers"
|
||||
### 1. filter + template
|
||||
### 2. filter + template + extra tag
|
||||
### 3. filter + template with field key
|
||||
### 4. default template
|
||||
templates = [
|
||||
"*.app env.service.resource.measurement",
|
||||
"stats.* .host.measurement* region=us-west,agent=sensu",
|
||||
|
||||
@@ -4,12 +4,6 @@ import (
|
||||
"github.com/influxdata/telegraf/internal/encoding/graphite"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultSeparator is the default join character to use when joining multiple
|
||||
// measurment parts in a template.
|
||||
DefaultSeparator = "."
|
||||
)
|
||||
|
||||
// Config represents the configuration for Graphite endpoints.
|
||||
type Config struct {
|
||||
Commands []string
|
||||
@@ -17,21 +11,15 @@ type Config struct {
|
||||
}
|
||||
|
||||
// New Config instance.
|
||||
func NewConfig(commands, tags, templates []string, separator string) *Config {
|
||||
func NewConfig(commands, templates []string, separator string) *Config {
|
||||
c := &Config{}
|
||||
if separator == "" {
|
||||
separator = graphite.DefaultSeparator
|
||||
}
|
||||
|
||||
c.Commands = commands
|
||||
c.Tags = tags
|
||||
c.Templates = templates
|
||||
c.Separator = separator
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// WithDefaults takes the given config and returns a new config with any required
|
||||
// default values set.
|
||||
func (c *Config) WithDefaults() *Config {
|
||||
d := *c
|
||||
if d.Separator == "" {
|
||||
d.Separator = DefaultSeparator
|
||||
}
|
||||
return &d
|
||||
}
|
||||
|
||||
@@ -32,19 +32,15 @@ const sampleConfig = `
|
||||
### If matching multiple measurement files, this string will be used to join the matched values.
|
||||
separator = "."
|
||||
|
||||
### Default tags that will be added to all metrics. These can be overridden at the template level
|
||||
### or by tags extracted from metric
|
||||
tags = ["region=north-east", "zone=1c"]
|
||||
|
||||
### Each template line requires a template pattern. It can have an optional
|
||||
### filter before the template and separated by spaces. It can also have optional extra
|
||||
### tags following the template. Multiple tags should be separated by commas and no spaces
|
||||
### similar to the line protocol format. The can be only one default template.
|
||||
### Templates support below format:
|
||||
### filter + template
|
||||
### filter + template + extra tag
|
||||
### filter + template with field key
|
||||
### default template. Ignore the first graphite component "servers"
|
||||
### 1. filter + template
|
||||
### 2. filter + template + extra tag
|
||||
### 3. filter + template with field key
|
||||
### 4. default template
|
||||
templates = [
|
||||
"*.app env.service.resource.measurement",
|
||||
"stats.* .host.measurement* region=us-west,agent=sensu",
|
||||
@@ -59,7 +55,6 @@ type Exec struct {
|
||||
DataFormat string
|
||||
|
||||
Separator string
|
||||
Tags []string
|
||||
Templates []string
|
||||
|
||||
encodingParser *encoding.Parser
|
||||
@@ -125,8 +120,7 @@ func (e *Exec) initConfig() error {
|
||||
e.Commands = []string{e.Command}
|
||||
}
|
||||
|
||||
c := NewConfig(e.Commands, e.Tags, e.Templates, e.Separator)
|
||||
c.WithDefaults()
|
||||
c := NewConfig(e.Commands, e.Templates, e.Separator)
|
||||
if err := c.Validate(); err != nil {
|
||||
return fmt.Errorf("exec configuration is error: %s ", err.Error())
|
||||
|
||||
@@ -134,9 +128,8 @@ func (e *Exec) initConfig() error {
|
||||
e.config = c
|
||||
|
||||
graphiteParser, err := graphite.NewParserWithOptions(graphite.Options{
|
||||
Templates: e.config.Templates,
|
||||
DefaultTags: e.config.DefaultTags(),
|
||||
Separator: e.config.Separator})
|
||||
Templates: e.config.Templates,
|
||||
Separator: e.config.Separator})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("exec input parser config is error: %s ", err.Error())
|
||||
@@ -152,7 +145,7 @@ func (e *Exec) SampleConfig() string {
|
||||
}
|
||||
|
||||
func (e *Exec) Description() string {
|
||||
return "Read metrics from one or more commands that output graphite line protocol to stdout"
|
||||
return "Read metrics from one or more commands that can output JSON, influx or graphite line protocol to stdout"
|
||||
}
|
||||
|
||||
func (e *Exec) Gather(acc telegraf.Accumulator) error {
|
||||
|
||||
Reference in New Issue
Block a user