Skip to content

Commit

Permalink
Merge pull request prometheus#1561 from prometheus/fabxc/alerterr
Browse files Browse the repository at this point in the history
Add error message if old alert rule tokens are read
  • Loading branch information
fabxc committed Apr 16, 2016
2 parents 78e43ff + fceedfa commit 64ed5d0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions promql/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"strings"
"unicode"
"unicode/utf8"

"github.com/prometheus/common/log"
)

// item represents a token or text string returned from the scanner.
Expand Down Expand Up @@ -173,6 +175,10 @@ const (
itemGroupLeft
itemGroupRight
itemBool
// Removed keywords. Just here to detect and print errors.
itemSummary
itemDescription
itemRunbook
keywordsEnd
)

Expand Down Expand Up @@ -206,6 +212,10 @@ var key = map[string]itemType{
"group_left": itemGroupLeft,
"group_right": itemGroupRight,
"bool": itemBool,
// Removed keywords. Just here to detect and print errors.
"summary": itemSummary,
"description": itemDescription,
"runbook": itemRunbook,
}

// These are the default string representations for common items. It does not
Expand Down Expand Up @@ -395,6 +405,12 @@ func (l *lexer) errorf(format string, args ...interface{}) stateFn {
func (l *lexer) nextItem() item {
item := <-l.items
l.lastPos = item.pos

// TODO(fabxc): remove for version 1.0.
t := item.typ
if t == itemSummary || t == itemDescription || t == itemRunbook {
log.Errorf("Token %q is not valid anymore. Alerting rule syntax has changed with version 0.17.0. Please read https://prometheus.io/docs/alerting/rules/.", item)
}
return item
}

Expand Down

0 comments on commit 64ed5d0

Please sign in to comment.