mquery
A Rust library for handling PROMQL (and possibly MetricsQL) queries.
Usage Example
use mquery::{Auth, QueryManager, query};
#[tokio::main]
async fn main() {
dotenv::dotenv().expect("No .env file found in working dir");
let url = std::env::var("VM_URL").expect("VM URL not found in env");
let token = std::env::var("VM_TOKEN").expect("VM token not found in env");
let query = query::Metric::new("total_http_requests").label_eq("method", "get");
let _response = QueryManager::new(url.parse().unwrap())
.auth(Auth::Bearer(token))
.query(query)
.await
.expect("operation failed");
}
Testing
Requires a local Victoria Metrics server running at http://127.0.0.1:8428/
for the integration tests to work.
Roadmap
- Basic raw queries (Instant and Ranged)
-
Query Builder
- Basic queries
- Operators
- Functions
- Runtime syntax checking
- Compile time syntax checking
- Deserialize to custom data types (with the help of proc-macros?)
- Encapsulated raw queries with methods for constructing interpolated versions