Skip to content

Commit

Permalink
Fixes unit in stats request log. (grafana#2093)
Browse files Browse the repository at this point in the history
* Fix unit conversion in stats log.

🤦

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

* Fix the tests because you know ! you know ?

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>

wip

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena committed May 19, 2020
1 parent c81be66 commit bd2bba6
Show file tree
Hide file tree
Showing 5 changed files with 1,022 additions and 1,051 deletions.
26 changes: 15 additions & 11 deletions pkg/logql/expr.y
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (
"time"
"github.com/prometheus/prometheus/pkg/labels"
)
type filter struct{
t labels.MatchType
m string
}
%}

%union{
Expr Expr
Filter labels.MatchType
Filter filter
Grouping *grouping
Labels []string
LogExpr LogSelectorExpr
Expand Down Expand Up @@ -48,7 +52,7 @@ import (
%type <BinOpExpr> binOpExpr
%type <LiteralExpr> literalExpr

%token <str> IDENTIFIER STRING NUMBER
%token <str> IDENTIFIER STRING NUMBER REGEX
%token <duration> DURATION
%token <val> MATCHERS LABELS EQ NEQ RE NRE OPEN_BRACE CLOSE_BRACE OPEN_BRACKET CLOSE_BRACKET COMMA DOT PIPE_MATCH PIPE_EXACT
OPEN_PARENTHESIS CLOSE_PARENTHESIS BY WITHOUT COUNT_OVER_TIME RATE SUM AVG MAX MIN COUNT STDDEV STDVAR BOTTOMK TOPK
Expand Down Expand Up @@ -79,17 +83,15 @@ metricExpr:

logExpr:
selector { $$ = newMatcherExpr($1)}
| logExpr filter STRING { $$ = NewFilterExpr( $1, $2, $3 ) }
| logExpr filter { $$ = NewFilterExpr( $1, $2.t, $2.m ) }
| OPEN_PARENTHESIS logExpr CLOSE_PARENTHESIS { $$ = $2 }
| logExpr filter error
| logExpr error
;

logRangeExpr:
logExpr DURATION { $$ = newLogRange($1, $2) } // <selector> <filters> <range>
| logRangeExpr filter STRING { $$ = addFilterToLogRangeExpr( $1, $2, $3 ) }
logExpr DURATION { $$ = newLogRange($1, $2) } // <selector> <filters> <range>
| logRangeExpr filter { $$ = addFilterToLogRangeExpr( $1, $2.t, $2.m ) }
| OPEN_PARENTHESIS logRangeExpr CLOSE_PARENTHESIS { $$ = $2 }
| logRangeExpr filter error
| logRangeExpr error
;

Expand All @@ -106,10 +108,12 @@ vectorAggregationExpr:
;

filter:
PIPE_MATCH { $$ = labels.MatchRegexp }
| PIPE_EXACT { $$ = labels.MatchEqual }
| NRE { $$ = labels.MatchNotRegexp }
| NEQ { $$ = labels.MatchNotEqual }
PIPE_MATCH STRING { $$ = filter{t:labels.MatchRegexp, m: $2 }}
| PIPE_MATCH REGEX { $$ = filter{t:labels.MatchRegexp, m: $2}}
| PIPE_EXACT STRING { $$ = filter{t:labels.MatchEqual, m: $2}}
| NRE STRING { $$ = filter{t:labels.MatchNotRegexp, m: $2 }}
| NRE REGEX { $$ = filter{t:labels.MatchNotRegexp, m: $2 }}
| NEQ STRING { $$ = filter{t:labels.MatchNotEqual, m: $2 }}
;

selector:
Expand Down
Loading

0 comments on commit bd2bba6

Please sign in to comment.