Expand description
Prometheus HTTP API
This crate provides data structures to interact with the prometheus HTTP API endpoints. The
crate allows constructing prometheus data sources with DataSourceBuilder
.
A Query
must be provided to the prometheus data source via the
DataSourceBuilder::with_query()
that acceps either a
InstantQuery
or a RangeQuery
, for these types, build-like methods
are provided for the optional parameters.
§Simple Usage
To gather the data from <http://localhost:9090/api/v1/query?query=up>
use prometheus_http_api::{
DataSourceBuilder, InstantQuery, Query,
};
#[tokio::main]
async fn main() {
let query = Query::Instant(InstantQuery::new("up"));
let request = DataSourceBuilder::new("localhost:9090")
.with_query(query)
.build()
.unwrap();
let res_json = request.get().await;
tracing::info!("{:?}", res_json);
}
Structs§
- Data
Source - Represents a prometheus data source that works over an http(s) host:port endpoint potentially behind a /prometheus_prefix/
- Data
Source Builder - A Builder struct to create the
DataSource
- Instant
Query - An instant query to send to Prometheus
- Matrix
Result MatrixResult
contains Prometheus Range Vectors- Range
Query - A range query to send to Prometheus
- Response
- A Prometheus
Response
returned by an HTTP query. - Vector
Result VectorResult
contains Prometheus Instant Vectors
Enums§
- Data
Source Error - A simple Error type to understand different errors.
- Query
- A query to the Prometheus HTTP API
- Response
Data - Available
ResponseData
formats documentation:https://prometheus.io/docs/prometheus/latest/querying/api/#expression-query-result-formats