diff --git a/model/textparse/promparse.go b/model/textparse/promparse.go index d84aafc25b..5aa3bfc1f6 100644 --- a/model/textparse/promparse.go +++ b/model/textparse/promparse.go @@ -443,12 +443,11 @@ func (p *PromParser) parseLVals() error { // and last character. p.offsets = append(p.offsets, p.l.start+1, p.l.i-1) - // Free trailing commas are allowed. - t = p.nextToken() - if t == tComma { + // Free trailing commas are allowed. NOTE: this allows spaces between label + // names, unlike in OpenMetrics. It is not clear if this is intended or an + // accidental bug. + if t = p.nextToken(); t == tComma { t = p.nextToken() - } else if t != tBraceClose { - return p.parseError("expected comma or brace close", t) } } } diff --git a/model/textparse/promparse_test.go b/model/textparse/promparse_test.go index 9032f32064..fa76df0a71 100644 --- a/model/textparse/promparse_test.go +++ b/model/textparse/promparse_test.go @@ -47,6 +47,7 @@ go_gc_duration_seconds{ quantile="1.0", a="b" } 8.3835e-05 go_gc_duration_seconds { quantile="1.0", a="b" } 8.3835e-05 go_gc_duration_seconds { quantile= "1.0", a= "b", } 8.3835e-05 go_gc_duration_seconds { quantile = "1.0", a = "b" } 8.3835e-05 +go_gc_duration_seconds { quantile = "2.0" a = "b" } 8.3835e-05 go_gc_duration_seconds_count 99 some:aggregate:rate5m{a_b="c"} 1 # HELP go_goroutines Number of goroutines that currently exist. @@ -129,6 +130,11 @@ testmetric{label="\"bar\""} 1` m: `go_gc_duration_seconds { quantile = "1.0", a = "b" }`, v: 8.3835e-05, lset: labels.FromStrings("__name__", "go_gc_duration_seconds", "quantile", "1.0", "a", "b"), + }, { + // NOTE: Unlike OpenMetrics, Promparse allows spaces between label terms. This appears to be unintended and should probably be fixed. + m: `go_gc_duration_seconds { quantile = "2.0" a = "b" }`, + v: 8.3835e-05, + lset: labels.FromStrings("__name__", "go_gc_duration_seconds", "quantile", "2.0", "a", "b"), }, { m: `go_gc_duration_seconds_count`, v: 99,