Change WITH keyword to LABELS

This commit is contained in:
Fabian Reinartz 2015-12-23 14:54:02 +01:00
parent 92c851f322
commit 4209ec6864
4 changed files with 12 additions and 10 deletions

View file

@ -153,7 +153,7 @@ const (
itemAlert itemAlert
itemIf itemIf
itemFor itemFor
itemWith itemLabels
itemAnnotations itemAnnotations
itemKeepCommon itemKeepCommon
itemOffset itemOffset
@ -183,7 +183,7 @@ var key = map[string]itemType{
"alert": itemAlert, "alert": itemAlert,
"if": itemIf, "if": itemIf,
"for": itemFor, "for": itemFor,
"with": itemWith, "labels": itemLabels,
"annotations": itemAnnotations, "annotations": itemAnnotations,
"offset": itemOffset, "offset": itemOffset,
"by": itemBy, "by": itemBy,

View file

@ -238,8 +238,8 @@ var tests = []struct {
input: "for", input: "for",
expected: []item{{itemFor, 0, "for"}}, expected: []item{{itemFor, 0, "for"}},
}, { }, {
input: "with", input: "labels",
expected: []item{{itemWith, 0, "with"}}, expected: []item{{itemLabels, 0, "labels"}},
}, { }, {
input: "annotations", input: "annotations",
expected: []item{{itemAnnotations, 0, "annotations"}}, expected: []item{{itemAnnotations, 0, "annotations"}},

View file

@ -358,7 +358,7 @@ func (p *parser) stmt() Statement {
// alertStmt parses an alert rule. // alertStmt parses an alert rule.
// //
// ALERT name IF expr [FOR duration] // ALERT name IF expr [FOR duration]
// [WITH label_set] // [LABELS label_set]
// [ANNOTATIONS label_set] // [ANNOTATIONS label_set]
// //
func (p *parser) alertStmt() *AlertStmt { func (p *parser) alertStmt() *AlertStmt {
@ -384,8 +384,8 @@ func (p *parser) alertStmt() *AlertStmt {
} }
lset := model.LabelSet{} lset := model.LabelSet{}
if p.peek().typ == itemWith { if p.peek().typ == itemLabels {
p.expect(itemWith, ctx) p.expect(itemLabels, ctx)
lset = p.labelSet() lset = p.labelSet()
} }

View file

@ -1149,7 +1149,8 @@ var testStatement = []struct {
dc:http_request:rate5m = sum(rate(http_request_count[5m])) by (dc) dc:http_request:rate5m = sum(rate(http_request_count[5m])) by (dc)
# A simple test alerting rule. # 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" service = "testservice"
# ... more fields here ... # ... more fields here ...
} }
@ -1284,7 +1285,8 @@ var testStatement = []struct {
}, { }, {
input: ` input: `
# A simple test alerting rule. # 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" service = "testservice"
# ... more fields here ... # ... more fields here ...
} }
@ -1332,7 +1334,7 @@ var testStatement = []struct {
input: `foo{a!~"b"} = bar`, input: `foo{a!~"b"} = bar`,
fail: true, fail: true,
}, { }, {
input: `ALERT SomeName IF time() WITH {} input: `ALERT SomeName IF time() LABELS {}
SUMMARY "Global request rate low" SUMMARY "Global request rate low"
DESCRIPTION "The global request rate is low" DESCRIPTION "The global request rate is low"
`, `,