PromQLEngine { public Query newRangeQuery(String qs, Instant start, Instant end, Duration interval) { Expr expr = Parser.parseExpr(qs); if (expr.type() != ValueType.vector && expr.type() != ValueType.scalar) { throw new IllegalStateException(String.format( "invalid expression type %s for range query, must be Scalar or instant Vector", typeString(expr.type()))); } Query qry = newQuery(expr, start, end, interval); qry.setQ(qs); return qry; } PromQLEngine(Storage storage);  PromQLEngine(Storage storage, EngineOptions options); Query newInstantQuery(String qs, Instant time); Query newRangeQuery(String qs, Instant start, Instant end, Duration interval); Value exec(Query query); Storage getStorage();  }
@Test public void newRangeQuery() { String promql = "sum_over_time(jvm.gc.young.count{app=\"lookout-gateway\"}[60s])"; Query query = engine.newRangeQuery(promql, Instant.parse("2019-05-29T10:29:30Z"), Instant.parse("2019-05-29T10:32:30Z"), Duration.ofSeconds(60)); Statement statement = query.getStmt(); Assert.assertNotNull(statement); Assert.assertTrue(statement instanceof EvalStmt); EvalStmt evalStmt = (EvalStmt) statement; Assert.assertEquals(60, evalStmt.getInterval().getSeconds()); }