Adding conjoined-field-names for graphite templates

pull/5562/head
Chris H (CruftMaster) 2016-02-06 13:32:28 +00:00 committed by Chris H (CruftMaster)
parent bb9eed941e
commit 2822b89481
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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 {