metricsql
implements a MetricsQL
and PromQL execution engine in Rust.
Define your datasource as a trait and execute timeseries queries against your data.
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Define your datasource
let provider = Arc::new(MyDataProvider::new());
// Create a Context, which will be used to provides session level config and services like caching and query stats
let ctx = Context::default().with_provider(provider);
let mut builder = QueryBuilder::default()
.start(Utc::now() - Duration::minutes(5))
.end(Utc::now())
.step(Duration::minutes(1))
.enable_tracing()
.query(r#"sum(rate(foo{bar="baz"}[5m])) by (job)"#);
let query_params = builder.build(&context)?;
// run arbitrary query against your datasource
let result = runtime::query_range(&context, query_params)?;
}
This code is under heavy development and is not ready for production or even casual use. The code base is also in heavy flux and will change frequently.
- Handles PromQL as well as a superset (MetricsQL). Note, however that 100% PromQL compatibility is not a goal.
- Over 200 supported functions (Aggregation, Rollup and Transformation)
- Builtin support for query rollup caching
- Builtin support for query tracing
- Uses Rayon for query execution parallelization
- Implement query parsing
- Implement basic query execution
- Implement query functions
- Test coverage
- Datafusion based provider. Expected support for
postgres
,mysql
, andsqlite
as well as file based sources likecsv
,json
andparquet
Contributions are welcome. Please open an issue to discuss your ideas before submitting a PR.
This project started as heavily modded rust
port of parts
of VictoriaMetrics.
The original code is licensed under the Apache 2.0 license.
Inspiration was also taken from
This project is licensed under the Apache 2.0.