|
|
@ -1852,6 +1852,48 @@ var testExpr = []struct {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Specifying __name__ twice inside the braces is ok.
|
|
|
|
|
|
|
|
input: `{__name__=~"bar", __name__!~"baz"}`,
|
|
|
|
|
|
|
|
expected: &VectorSelector{
|
|
|
|
|
|
|
|
LabelMatchers: []*labels.Matcher{
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchRegexp, model.MetricNameLabel, "bar"),
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchNotRegexp, model.MetricNameLabel, "baz"),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
PosRange: posrange.PositionRange{
|
|
|
|
|
|
|
|
Start: 0,
|
|
|
|
|
|
|
|
End: 34,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Specifying __name__ with equality twice inside the braces is even allowed.
|
|
|
|
|
|
|
|
input: `{__name__="bar", __name__="baz"}`,
|
|
|
|
|
|
|
|
expected: &VectorSelector{
|
|
|
|
|
|
|
|
LabelMatchers: []*labels.Matcher{
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, "bar"),
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, "baz"),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
PosRange: posrange.PositionRange{
|
|
|
|
|
|
|
|
Start: 0,
|
|
|
|
|
|
|
|
End: 32,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Because the above are allowed, this is also allowed.
|
|
|
|
|
|
|
|
input: `{"bar", __name__="baz"}`,
|
|
|
|
|
|
|
|
expected: &VectorSelector{
|
|
|
|
|
|
|
|
LabelMatchers: []*labels.Matcher{
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, "bar"),
|
|
|
|
|
|
|
|
MustLabelMatcher(labels.MatchEqual, model.MetricNameLabel, "baz"),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
PosRange: posrange.PositionRange{
|
|
|
|
|
|
|
|
Start: 0,
|
|
|
|
|
|
|
|
End: 23,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
input: `{`,
|
|
|
|
input: `{`,
|
|
|
|
fail: true,
|
|
|
|
fail: true,
|
|
|
@ -1934,6 +1976,8 @@ var testExpr = []struct {
|
|
|
|
fail: true,
|
|
|
|
fail: true,
|
|
|
|
errMsg: "vector selector must contain at least one non-empty matcher",
|
|
|
|
errMsg: "vector selector must contain at least one non-empty matcher",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Although {"bar", __name__="baz"} is allowed (see above), specifying a
|
|
|
|
|
|
|
|
// metric name inside and outside the braces is not.
|
|
|
|
{
|
|
|
|
{
|
|
|
|
input: `foo{__name__="bar"}`,
|
|
|
|
input: `foo{__name__="bar"}`,
|
|
|
|
fail: true,
|
|
|
|
fail: true,
|
|
|
|