Skip to content

Commit

Permalink
Merge pull request prometheus#31 from promlabs/feature/negative-offset
Browse files Browse the repository at this point in the history
support negative offset
  • Loading branch information
juliusv authored Mar 24, 2021
2 parents f15df99 + df7754c commit 81dd0a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/promql.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ ParenExpr {
}

OffsetExpr {
Expr Offset Duration
Expr Offset Sub? Duration
}

MatrixSelector {
Expand Down
21 changes: 21 additions & 0 deletions test/expression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,24 @@ Inf{foo="bar"}

==>
PromQL(Expr(BinaryExpr(Expr(NumberLiteral),⚠,BinModifiers,Expr(VectorSelector(LabelMatchers(LabelMatchList(LabelMatcher(LabelName,MatchOp(EqlSingle),StringLiteral))))))))

# Negative offset

foo offset -5d

==>
PromQL(Expr(OffsetExpr(Expr(VectorSelector(MetricIdentifier(Identifier))), Offset, Sub, Duration)))

# Negative offset with space

foo offset - 5d

==>
PromQL(Expr(OffsetExpr(Expr(VectorSelector(MetricIdentifier(Identifier))), Offset, Sub, Duration)))

# Positive offset

foo offset 5d

==>
PromQL(Expr(OffsetExpr(Expr(VectorSelector(MetricIdentifier(Identifier))), Offset, Duration)))

0 comments on commit 81dd0a3

Please sign in to comment.