Skip to content

Commit

Permalink
PromQL: Allow more keywords as metric names (prometheus#6933)
Browse files Browse the repository at this point in the history
* Allow more keywords as metric names
* Add documentation about forbidden keywords

Signed-off-by: Tobias Guggenmos <[email protected]>
  • Loading branch information
brian-brazil authored Mar 5, 2020
1 parent 7164b58 commit 44ad28d
Show file tree
Hide file tree
Showing 4 changed files with 353 additions and 213 deletions.
8 changes: 8 additions & 0 deletions docs/querying/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ The following expression selects all metrics that have a name starting with `job

{__name__=~"job:.*"}

The metric name must not be one of the keywords `bool`, `on`, `ignoring`, `group_left` and `group_right`. The following expression is illegal:

on{} # Bad!

A workaround for this restriction is to use the `__name__` label:

{__name__="on"} # Good!

All regular expressions in Prometheus use [RE2
syntax](https://github.com/google/re2/wiki/Syntax).

Expand Down
2 changes: 1 addition & 1 deletion promql/parser/generated_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ metric : metric_identifier label_set
;


metric_identifier: METRIC_IDENTIFIER | IDENTIFIER;
metric_identifier: AVG | BOTTOMK | BY | COUNT | COUNT_VALUES | IDENTIFIER | LAND | LOR | LUNLESS | MAX | METRIC_IDENTIFIER | MIN | OFFSET | QUANTILE | STDDEV | STDVAR | SUM | TOPK;

label_set : LEFT_BRACE label_set_list RIGHT_BRACE
{ $$ = labels.New($2...) }
Expand Down
Loading

0 comments on commit 44ad28d

Please sign in to comment.