From ab3d7a0ec03021ace5a3a39dc6fb108cdf6cc0b3 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Wed, 23 Mar 2016 10:19:00 +0100 Subject: [PATCH] Remove old alerting syntax --- promql/lex.go | 11 ---------- promql/lex_test.go | 12 ----------- promql/parse.go | 48 ++++---------------------------------------- promql/parse_test.go | 26 ------------------------ 4 files changed, 4 insertions(+), 93 deletions(-) diff --git a/promql/lex.go b/promql/lex.go index 90f82f373..5d390ca11 100644 --- a/promql/lex.go +++ b/promql/lex.go @@ -163,11 +163,6 @@ const ( itemGroupLeft itemGroupRight itemBool - // Old alerting syntax - itemWith - itemSummary - itemRunbook - itemDescription keywordsEnd ) @@ -200,12 +195,6 @@ var key = map[string]itemType{ "group_left": itemGroupLeft, "group_right": itemGroupRight, "bool": itemBool, - - // Old alerting syntax. - "with": itemWith, - "summary": itemSummary, - "runbook": itemRunbook, - "description": itemDescription, } // These are the default string representations for common items. It does not diff --git a/promql/lex_test.go b/promql/lex_test.go index 9ff8e4420..d516c3d93 100644 --- a/promql/lex_test.go +++ b/promql/lex_test.go @@ -263,18 +263,6 @@ var tests = []struct { }, { input: "annotations", expected: []item{{itemAnnotations, 0, "annotations"}}, - }, { - input: "description", - expected: []item{{itemDescription, 0, "description"}}, - }, { - input: "summary", - expected: []item{{itemSummary, 0, "summary"}}, - }, { - input: "runbook", - expected: []item{{itemRunbook, 0, "runbook"}}, - }, { - input: "with", - expected: []item{{itemWith, 0, "with"}}, }, { input: "offset", expected: []item{{itemOffset, 0, "offset"}}, diff --git a/promql/parse.go b/promql/parse.go index 758d87922..c91df6fb3 100644 --- a/promql/parse.go +++ b/promql/parse.go @@ -384,57 +384,17 @@ func (p *parser) alertStmt() *AlertStmt { } } - // Accepting WITH instead of LABELS is temporary compatibility - // with the old alerting syntax. var ( - hasLabels bool - oldSyntax bool labels = model.LabelSet{} annotations = model.LabelSet{} ) - if t := p.peek().typ; t == itemLabels { + if p.peek().typ == itemLabels { p.expect(itemLabels, ctx) labels = p.labelSet() - hasLabels = true - } else if t == itemWith { - p.expect(itemWith, ctx) - labels = p.labelSet() - oldSyntax = true } - - // Only allow old annotation syntax if new label syntax isn't used. - if !hasLabels { - Loop: - for { - switch p.next().typ { - case itemSummary: - annotations["summary"] = model.LabelValue(p.unquoteString(p.expect(itemString, ctx).val)) - - case itemDescription: - annotations["description"] = model.LabelValue(p.unquoteString(p.expect(itemString, ctx).val)) - - case itemRunbook: - annotations["runbook"] = model.LabelValue(p.unquoteString(p.expect(itemString, ctx).val)) - - default: - p.backup() - break Loop - } - } - if len(annotations) > 0 { - oldSyntax = true - } - } - - // Only allow new annotation syntax if WITH or old annotation - // syntax weren't used. - if !oldSyntax { - if p.peek().typ == itemAnnotations { - p.expect(itemAnnotations, ctx) - annotations = p.labelSet() - } - } else { - log.Warnf("Alerting rule with old syntax found. Support for this syntax will be removed with 0.18. Please update to the new syntax.") + if p.peek().typ == itemAnnotations { + p.expect(itemAnnotations, ctx) + annotations = p.labelSet() } return &AlertStmt{ diff --git a/promql/parse_test.go b/promql/parse_test.go index 28a12a677..b438d2ec8 100644 --- a/promql/parse_test.go +++ b/promql/parse_test.go @@ -1311,32 +1311,6 @@ var testStatement = []struct { Labels: model.LabelSet{"x": "", "a": "z"}, }, }, - }, { - input: `ALERT SomeName IF some_metric > 1 - WITH {} - SUMMARY "Global request rate low" - DESCRIPTION "The global request rate is low" - `, - expected: Statements{ - &AlertStmt{ - Name: "SomeName", - Expr: &BinaryExpr{ - Op: itemGTR, - LHS: &VectorSelector{ - Name: "some_metric", - LabelMatchers: metric.LabelMatchers{ - {Type: metric.Equal, Name: model.MetricNameLabel, Value: "some_metric"}, - }, - }, - RHS: &NumberLiteral{1}, - }, - Labels: model.LabelSet{}, - Annotations: model.LabelSet{ - "summary": "Global request rate low", - "description": "The global request rate is low", - }, - }, - }, }, { input: `ALERT SomeName IF some_metric > 1 LABELS {}