For example:
PROMQL step=?_step rate(http_requests_total[?_step])
This should work already: step=?_step. Parameters are resolved with ExpressionBuilder#paramByNameOrPosition.
This isn't supported yet: rate(http_requests_total[?_step]). We get an ANTLR ParsingException (no viable alternative at input 'rate(http_requests_total[?') here because the PromQL grammar doesn't support parameters.
The quick and dirty workaround would be to replace parameters in the opaque promqlQuery string before invoking the PromQL parser:
|
promqlPlan = promqlParser.createStatement( |
|
promqlQuery, |
|
params.startLiteral(), |
|
params.endLiteral(), |
|
promqlStartLine, |
|
promqlStartColumn |
|
); |
Another option is to adjust the PromQL grammar itself to add support for parameters. This lets us control in a more fine-grained way where we support double and single params. That's likely a bit more involved and we'll need to re-implement things in PromqlExpressionBuilder but my first instinct is that this is a the cleaner solution.
For example:
This should work already:
step=?_step. Parameters are resolved withExpressionBuilder#paramByNameOrPosition.This isn't supported yet:
rate(http_requests_total[?_step]). We get an ANTLR ParsingException (no viable alternative at input 'rate(http_requests_total[?') here because the PromQL grammar doesn't support parameters.The quick and dirty workaround would be to replace parameters in the opaque
promqlQuerystring before invoking the PromQL parser:elasticsearch/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java
Lines 1284 to 1290 in 99ced4f
Another option is to adjust the PromQL grammar itself to add support for parameters. This lets us control in a more fine-grained way where we support double and single params. That's likely a bit more involved and we'll need to re-implement things in
PromqlExpressionBuilderbut my first instinct is that this is a the cleaner solution.