diff --git a/lib/protoparser/prometheus/parser.go b/lib/protoparser/prometheus/parser.go index e76a3026c..bacccffa0 100644 --- a/lib/protoparser/prometheus/parser.go +++ b/lib/protoparser/prometheus/parser.go @@ -236,7 +236,7 @@ func unmarshalTags(dst []Tag, s string, noEscapes bool) (string, []Tag, error) { if len(s) == 0 || s[0] != ',' { return s, dst, fmt.Errorf("missing comma after tag %s=%q", key, value) } - s = s[1:] + s = skipLeadingWhitespace(s[1:]) } } diff --git a/lib/protoparser/prometheus/parser_test.go b/lib/protoparser/prometheus/parser_test.go index b1517da6d..3a5628c72 100644 --- a/lib/protoparser/prometheus/parser_test.go +++ b/lib/protoparser/prometheus/parser_test.go @@ -253,7 +253,7 @@ func TestRowsUnmarshalSuccess(t *testing.T) { }) // Multi lines with invalid line - f("\t foo\t {} 0.3\t 2\naaa\n bar.baz 0.34 43\n", &Rows{ + f("\t foo\t { } 0.3\t 2\naaa\n bar.baz 0.34 43\n", &Rows{ Rows: []Row{ { Metric: "foo", @@ -267,4 +267,29 @@ func TestRowsUnmarshalSuccess(t *testing.T) { }, }, }) + + // Spaces around tags + f(`vm_accounting { name="vminsertRows", accountID = "1" , projectID= "1" } 277779100`, &Rows{ + Rows: []Row{ + { + Metric: "vm_accounting", + Tags: []Tag{ + { + Key: "name", + Value: "vminsertRows", + }, + { + Key: "accountID", + Value: "1", + }, + { + Key: "projectID", + Value: "1", + }, + }, + Value: 277779100, + Timestamp: 0, + }, + }, + }) }