validates that the recording name to include only allowed characters. (#3305)

This commit is contained in:
Krasi Georgiev 2017-10-17 12:22:59 +03:00 committed by Brian Brazil
parent 9ef8518b37
commit 3697075b8f
3 changed files with 12 additions and 0 deletions

View file

@ -127,6 +127,9 @@ func (r *Rule) Validate() (errs []error) {
if r.For != 0 {
errs = append(errs, errors.Errorf("invalid field 'for' in recording rule"))
}
if !model.IsValidMetricName(model.LabelValue(r.Record)) {
errs = append(errs, errors.Errorf("invalid recording rule name: %s", r.Record))
}
}
for k, v := range r.Labels {

View file

@ -61,6 +61,10 @@ func TestParseFileFailure(t *testing.T) {
filename: "bad_annotation.bad.yaml",
errMsg: "invalid annotation name",
},
{
filename: "invalid_record_name.bad.yaml",
errMsg: "invalid recording rule name",
},
}
for _, c := range table {

View file

@ -0,0 +1,5 @@
groups:
- name: yolo
rules:
- record: strawberry{flavor="sweet"}
expr: 1