Crates.io | prometheus-http-api-rs |
lib.rs | prometheus-http-api-rs |
version | 0.1.0 |
source | src |
created_at | 2022-04-26 09:07:59.262496 |
updated_at | 2022-04-26 09:07:59.262496 |
description | API to interact with Prometheus HTTP API |
homepage | |
repository | https://github.com/sebosp/prometheus-http-api-rs |
max_upload_size | |
id | 575227 |
size | 35,290 |
A simple library to pull data from prometheus using its API
Upcoming docs crate documentation.
Add dependency in Cargo.toml
:
[dependencies]
prometheus-http-api-rs = "0.0.1"
Use prometheus_http_api_rs
use prometheus_http_api_rs::*;
#[tokio::main]
async fn main() {
let query = PrometheusQuery::Instant(PrometheusInstantQuery::new("up".to_string()));
let request = PrometheusDataSourceBuilder::new("localhost:9090".to_string())
.with_query(query)
.build()
.unwrap();
let res_json = request.get().await;
tracing::info!("{:?}", res_json);
}
Instant
support, currently we only support epochs as params./api/v1/series
or /api/v1/labels
/api/v1/label/<label_name>/values
/api/v1/targets
/api/v1/alertmanagers
/api/v1/status/config
/api/v1/status/flags
/api/v1/status/runtimeinfo
, available since prometheus v2.2/api/v1/status/buildinfo
, available since prometheus v2.14/api/v1/status/tsdb
, available since prometheus v2.14/api/v1/status/walreplay
available since prometheus v2.15/api/v1/query_exemplars
(experimental)/api/v1/rules
(doesn't have stability guarantees from prometheus v1)/api/v1/alerts
(doesn't have stability guarantees from prometheus v1)/api/v1/targets/metadata
(experimental)/api/v1/metadata
(experimental)Since prometheus v2.18, require -web.enable-admin-api
/api/v1/admin/tsdb/snapshot
/api/v1/admin/tsdb/delete_series
/api/v1/admin/tsdb/clean_tombstones
Requires --web.enable-remote-write-receiver
.
/api/v1/write
since prometheus v2.33 not efficient way to push data.json::Value
is not necessarily a number, it may be a string:JSON does not support special float values such as NaN, Inf, and -Inf, so sample values are transferred as quoted JSON strings rather than raw numbers.