From 2822b894812ec6b585e3e759f7888026e1d2a1cb Mon Sep 17 00:00:00 2001 From: "Chris H (CruftMaster)" Date: Sat, 6 Feb 2016 13:32:28 +0000 Subject: [PATCH] Adding conjoined-field-names for graphite templates --- services/graphite/parser.go | 3 +++ services/graphite/parser_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/services/graphite/parser.go b/services/graphite/parser.go index 0bdf42f31a..6045dc399c 100644 --- a/services/graphite/parser.go +++ b/services/graphite/parser.go @@ -237,6 +237,9 @@ func (t *template) Apply(line string) (string, map[string]string, string, error) return "", nil, "", fmt.Errorf("'field' can only be used once in each template: %q", line) } field = fields[i] + } else if tag == "field*" { + field = strings.Join(fields[i:], "_") + break } else if tag == "measurement*" { measurement = append(measurement, fields[i:]...) break diff --git a/services/graphite/parser_test.go b/services/graphite/parser_test.go index 1a80c3d936..ba813a125a 100644 --- a/services/graphite/parser_test.go +++ b/services/graphite/parser_test.go @@ -100,6 +100,13 @@ func TestTemplateApply(t *testing.T) { measurement: "cpu.load", tags: map[string]string{"zone": "us-west"}, }, + { + test: "conjoined fields", + input: "prod.us-west.server01.cpu.util.idle.percent", + template: "env.zone.host.measurement.measurement.field*", + measurement: "cpu.util", + tags: map[string]string{"env": "prod", "zone": "us-west", "host": "server01"}, + }, } for _, test := range tests {