Merge pull request #1272 from prometheus/labelskw

Change WITH keyword to LABELS
This commit is contained in:
Fabian Reinartz 2015-12-23 15:14:03 +01:00
commit 60287319d3
4 changed files with 12 additions and 10 deletions

View File

@ -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,

View File

@ -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"}},

View File

@ -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()
}

View File

@ -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"
`,