diff --git a/promql/lex.go b/promql/lex.go index 5e71c96a5..2ebb9cc8a 100644 --- a/promql/lex.go +++ b/promql/lex.go @@ -153,7 +153,7 @@ const ( itemAlert itemIf itemFor - itemWith + itemLabels itemAnnotations itemKeepCommon itemOffset @@ -183,7 +183,7 @@ var key = map[string]itemType{ "alert": itemAlert, "if": itemIf, "for": itemFor, - "with": itemWith, + "labels": itemLabels, "annotations": itemAnnotations, "offset": itemOffset, "by": itemBy, diff --git a/promql/lex_test.go b/promql/lex_test.go index 5811b9689..793621a3d 100644 --- a/promql/lex_test.go +++ b/promql/lex_test.go @@ -238,8 +238,8 @@ var tests = []struct { input: "for", expected: []item{{itemFor, 0, "for"}}, }, { - input: "with", - expected: []item{{itemWith, 0, "with"}}, + input: "labels", + expected: []item{{itemLabels, 0, "labels"}}, }, { input: "annotations", expected: []item{{itemAnnotations, 0, "annotations"}}, diff --git a/promql/parse.go b/promql/parse.go index 7e2be267b..7e261a225 100644 --- a/promql/parse.go +++ b/promql/parse.go @@ -358,7 +358,7 @@ func (p *parser) stmt() Statement { // alertStmt parses an alert rule. // // ALERT name IF expr [FOR duration] -// [WITH label_set] +// [LABELS label_set] // [ANNOTATIONS label_set] // func (p *parser) alertStmt() *AlertStmt { @@ -384,8 +384,8 @@ func (p *parser) alertStmt() *AlertStmt { } lset := model.LabelSet{} - if p.peek().typ == itemWith { - p.expect(itemWith, ctx) + if p.peek().typ == itemLabels { + p.expect(itemLabels, ctx) lset = p.labelSet() } diff --git a/promql/parse_test.go b/promql/parse_test.go index 43b62c8a6..4a544cd5e 100644 --- a/promql/parse_test.go +++ b/promql/parse_test.go @@ -1149,7 +1149,8 @@ var testStatement = []struct { dc:http_request:rate5m = sum(rate(http_request_count[5m])) by (dc) # A simple test alerting rule. - ALERT GlobalRequestRateLow IF(dc:http_request:rate5m < 10000) FOR 5m WITH { + ALERT GlobalRequestRateLow IF(dc:http_request:rate5m < 10000) FOR 5m + LABELS { service = "testservice" # ... more fields here ... } @@ -1284,7 +1285,8 @@ var testStatement = []struct { }, { input: ` # A simple test alerting rule. - ALERT GlobalRequestRateLow IF(dc:http_request:rate5m < 10000) FOR 5 WITH { + ALERT GlobalRequestRateLow IF(dc:http_request:rate5m < 10000) FOR 5 + LABELS { service = "testservice" # ... more fields here ... } @@ -1332,7 +1334,7 @@ var testStatement = []struct { input: `foo{a!~"b"} = bar`, fail: true, }, { - input: `ALERT SomeName IF time() WITH {} + input: `ALERT SomeName IF time() LABELS {} SUMMARY "Global request rate low" DESCRIPTION "The global request rate is low" `,