prometheus-http-client
Makes requests to the prometheus query API. With plot feature, also provides
a way to plot responses from prometheus.
Why a custom implementation?
There are several prometheus query clients for Rust, but none quite fit the requirements:
prometheus-http-query
The most complete and actively maintained option. However, it uses a structured
Selector builder that doesn't support raw PromQL selector strings. This means
queries like __name__=~"http_.*" or complex label matchers must be constructed
programmatically rather than passed as strings. For use cases where selectors
come from configuration files or user input, this is a significant limitation.
prometheus-http-api
Supports raw selector strings, which is great. However, it only implements
instant and range queries (/api/v1/query and /api/v1/query_range). It lacks
support for /api/v1/series, /api/v1/labels, /api/v1/label/.../values,
and /api/v1/alerts endpoints that this crate uses.
proq / prometheus-query
Both are unmaintained (last updates 4+ years ago) and use outdated dependencies
like tokio 0.1 and hyper 0.12.
This crate
This implementation supports both raw PromQL selector strings and the full set of
API endpoints needed (query, query_range, series, labels, label values, alerts).
The plot feature adds time-series visualization using plotters.