mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-29 07:29:42 -08:00
Merge pull request #1964 from prometheus/release-1.1
Forward-merge the bug fix from release-1.1
This commit is contained in:
commit
e5a5dc172d
|
@ -1,3 +1,7 @@
|
||||||
|
## 1.1.2 / 2016-09-08
|
||||||
|
|
||||||
|
* [BUGFIX] Allow label names that coincide with keywords.
|
||||||
|
|
||||||
## 1.1.1 / 2016-09-07
|
## 1.1.1 / 2016-09-07
|
||||||
|
|
||||||
* [BUGFIX] Fix IPv6 escaping in service discovery integrations
|
* [BUGFIX] Fix IPv6 escaping in service discovery integrations
|
||||||
|
|
|
@ -889,3 +889,16 @@ func isDigit(r rune) bool {
|
||||||
func isAlpha(r rune) bool {
|
func isAlpha(r rune) bool {
|
||||||
return r == '_' || ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z')
|
return r == '_' || ('a' <= r && r <= 'z') || ('A' <= r && r <= 'Z')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isLabel reports whether the string can be used as label.
|
||||||
|
func isLabel(s string) bool {
|
||||||
|
if len(s) == 0 || !isAlpha(rune(s[0])) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, c := range s[1:] {
|
||||||
|
if !isAlphaNumeric(c) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -673,7 +673,10 @@ func (p *parser) labels() model.LabelNames {
|
||||||
labels := model.LabelNames{}
|
labels := model.LabelNames{}
|
||||||
if p.peek().typ != itemRightParen {
|
if p.peek().typ != itemRightParen {
|
||||||
for {
|
for {
|
||||||
id := p.expect(itemIdentifier, ctx)
|
id := p.next()
|
||||||
|
if !isLabel(id.val) {
|
||||||
|
p.errorf("unexpected %s in %s, expected label", id.desc(), ctx)
|
||||||
|
}
|
||||||
labels = append(labels, model.LabelName(id.val))
|
labels = append(labels, model.LabelName(id.val))
|
||||||
|
|
||||||
if p.peek().typ != itemComma {
|
if p.peek().typ != itemComma {
|
||||||
|
|
|
@ -1225,6 +1225,24 @@ var testExpr = []struct {
|
||||||
},
|
},
|
||||||
Param: &StringLiteral{"value"},
|
Param: &StringLiteral{"value"},
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
// Test usage of keywords as label names.
|
||||||
|
input: "sum without(and, by, avg, count, alert, annotations)(some_metric)",
|
||||||
|
expected: &AggregateExpr{
|
||||||
|
Op: itemSum,
|
||||||
|
Without: true,
|
||||||
|
Expr: &VectorSelector{
|
||||||
|
Name: "some_metric",
|
||||||
|
LabelMatchers: metric.LabelMatchers{
|
||||||
|
mustLabelMatcher(metric.Equal, model.MetricNameLabel, "some_metric"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Grouping: model.LabelNames{"and", "by", "avg", "count", "alert", "annotations"},
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
input: "sum without(==)(some_metric)",
|
||||||
|
fail: true,
|
||||||
|
errMsg: "unexpected <op:==> in grouping opts, expected label",
|
||||||
}, {
|
}, {
|
||||||
input: `sum some_metric by (test)`,
|
input: `sum some_metric by (test)`,
|
||||||
fail: true,
|
fail: true,
|
||||||
|
|
Loading…
Reference in a new issue