diff --git a/pkg/proxystorage/proxy.go b/pkg/proxystorage/proxy.go index e0da4064f..e5071056b 100644 --- a/pkg/proxystorage/proxy.go +++ b/pkg/proxystorage/proxy.go @@ -299,7 +299,7 @@ func (p *ProxyStorage) NodeReplacer(ctx context.Context, s *promql.EvalStmt, nod Op: promql.ItemDIV, LHS: &promql.AggregateExpr{ Op: promql.ItemSum, - Expr: n.Expr, + Expr: CloneExpr(n.Expr), Param: n.Param, Grouping: n.Grouping, Without: n.Without, @@ -307,7 +307,7 @@ func (p *ProxyStorage) NodeReplacer(ctx context.Context, s *promql.EvalStmt, nod RHS: &promql.AggregateExpr{ Op: promql.ItemCount, - Expr: n.Expr, + Expr: CloneExpr(n.Expr), Param: n.Param, Grouping: n.Grouping, Without: n.Without, diff --git a/pkg/proxystorage/util.go b/pkg/proxystorage/util.go index df56eac7f..b22f97299 100644 --- a/pkg/proxystorage/util.go +++ b/pkg/proxystorage/util.go @@ -110,3 +110,8 @@ func (f *BooleanFinder) Visit(node promql.Node, _ []promql.Node) (promql.Visitor } return f, nil } + +func CloneExpr(expr promql.Expr) (newExpr promql.Expr) { + newExpr, _ = promql.ParseExpr(expr.String()) + return +}