diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a054d392..b65c68c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ continue sending logs to /var/log/telegraf/telegraf.log. - [#1854](https://github.com/influxdata/telegraf/pull/1853): SQL Server waitstats truncation bug. - [#1810](https://github.com/influxdata/telegraf/issues/1810): Fix logparser common log format: numbers in ident. - [#1793](https://github.com/influxdata/telegraf/pull/1793): Fix JSON Serialization in OpenTSDB output. +- [#1731](https://github.com/influxdata/telegraf/issues/1731): Fix Graphite template ordering, use most specific. ## v1.0.1 [2016-09-26] diff --git a/docs/DATA_FORMATS_INPUT.md b/docs/DATA_FORMATS_INPUT.md index 2e3a479ac..c14752d9c 100644 --- a/docs/DATA_FORMATS_INPUT.md +++ b/docs/DATA_FORMATS_INPUT.md @@ -232,6 +232,16 @@ us.west.cpu.load 100 => cpu.load,region=us.west value=100 ``` +Multiple templates can also be specified, but these should be differentiated +using _filters_ (see below for more details) + +```toml +templates = [ + "*.*.* region.region.measurement", # <- all 3-part measurements will match this one. + "*.*.*.* region.region.host.measurement", # <- all 4-part measurements will match this one. +] +``` + #### Field Templates: The field keyword tells Telegraf to give the metric that field name. diff --git a/plugins/parsers/graphite/parser.go b/plugins/parsers/graphite/parser.go index d371274df..4a3c21df9 100644 --- a/plugins/parsers/graphite/parser.go +++ b/plugins/parsers/graphite/parser.go @@ -57,38 +57,34 @@ func NewGraphiteParser( defaultTemplate, _ := NewTemplate("measurement*", nil, p.Separator) matcher.AddDefaultTemplate(defaultTemplate) + tmplts := parsedTemplates{} for _, pattern := range p.Templates { - template := pattern - filter := "" + tmplt := parsedTemplate{} + tmplt.template = pattern // Format is [filter]