NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #4671 most downloaded on crates.io
Prometheus HTTP API client
Latest stable
0.9.0
Last release 6 months ago
09 May 2026
Ships unpredictably
gaps range from 2 weeks to 2.1 years
Most releases are documented
notes for 26 of 29 stable releases
1 version withdrawn
withdrawn after publishing
6 years old
30 releases · first in 2021
Drag across the ruler to compare, or tap a release to open it.
Thank you @scvalex and @drbrain for the contributions!
See CHANGELOG
Thank you @scvalex and @drbrain for the contributions!
While the crate is not regularly updated anymore, I appreciate every PR created in this repository and try to merge contributions diligently.
reqwest to avoid having to manage multiple, possibly conflicting dependencies to the same crate in a user's Cargo.toml (thanks to @svcalex via pull request)reqwest in Cargo.toml to 0.13 (thanks to @drbrain via pull request)0.8.4See CHANGELOG Thanks to @chris13524
Your coding agent can read these notes before it upgrades. Set up the MCP server →
See CHANGELOG
Thanks to @chris13524
reqwest to v12.x (@chris13524 via pull request)url to v2.5See CHANGELOG Thanks to @alesharik !
See CHANGELOG
Thanks to @alesharik !
InstantQueryBuilder::queryRangeQueryBuilder::queryAll changes by courtesy of @alesharik via pull request.
See CHANGELOG Thanks to @VoltaireNoir !
See CHANGELOG
Thanks to @VoltaireNoir !
InstantQueryBuilder::get_rawInstantQueryBuilder::post_rawRangeQueryBuilder::get_rawRangeQueryBuilder::post_rawLabelNamesQueryBuilder::get_rawLabelValuesQueryBuilder::get_rawMetricMetadataQueryBuilder::get_rawRulesQueryBuilder::get_rawSeriesQueryBuilder::get_rawTargetMetadataQueryBuilder::get_rawAll changes by courtesy of @VoltaireNoir via pull request.
See CHANGELOG Thanks to @VoltaireNoir !
See CHANGELOG
Thanks to @VoltaireNoir !
Copy on SampleData::as_vector_mutData::as_matrix_mutData::as_scalar_mutData::into_vectorData::into_matrixData::into_samplePromqlResult::into_innerData::as_vector returns Option<&Vec<InstantVector>> nowData::as_matrix returns Option<&Vec<RangeVector>> nowNote that this is technically a breaking release due to the altered function signatures of the two functions above. These functions formerly returned Option<&[InstantVector]>. However thanks to Rust's type coercions rules the changes are actually not expected to break any code, since the returned vector is yet again coerced to a slice when accessed immutably.
All changes by courtesy of @VoltaireNoir via pull request.
See CHANGELOG
See CHANGELOG
See CHANGELOG
RuleGroup::limit()RuleGroup::last_evaluation()RuleGroup::evaluation_time()AlertingRule::last_evaluation()AlertingRule::evaluation_time()RecordingRule::last_evaluation()RecordingRule::evaluation_time()Rule::as_recording()Rule::as_alerting()impl Eq for RuleHealthRuleHealth::is_good()RuleHealth::is_bad()RuleHealth::is_unknown()impl Eq for AlertStateAlertState::is_inactive()AlertState::is_pending()AlertState::is_firing()impl Eq for TargetHealthTargetHealth::is_up()TargetHealth::is_down()TargetHealth::is_unknown()impl Eq for MetricTypeMetricType::is_counter()MetricType::is_gauge()MetricType::is_histogram()MetricType::is_gauge_histogram()MetricType::is_summary()MetricType::is_info()MetricType::is_stateset()MetricType::is_unknown()AlertingRule::keep_firing_for()impl Eq for WalReplayStateWalReplayState::is_waiting()WalReplayState::is_in_progress()WalReplayState::is_done()Among other changes some Client methods have been refactored and return "builders" (like Client::query and Client::query_range already did) to gradually build a query to the respective endpoint instead of having to pass a lot of arguments to a single function and also having to pass None a lot to use the "default" functionality of the given Prometheus API endpoint.
The following Client methods were refactored in that fashion:
Client::rules()Client::target_metadata()Client::metric_metadata()Client::series()Client::label_names()Client::label_values()Other changes include:
RuleType to RuleKind and its variants from Alert and Record to Alerting and Recording.Alert::value() now returns f64.Client::query, Client::query_range direct::query and direct::query_range now require the PromQl query string to implement std::fmt::Display instead of std::string::ToString.serde_json could be removed.error module and some custom errors related to deserialization using serde::de::Error. The Error enum inside the error module now contains one variant less and existing error variants were improved by properly implementing std::error::Error::source(). Libraries like anyhow are now able to display more detailed error messages. This change is not breaking if you did not match on specific error enum variants before.Client methods now return a more concise error if the server response (from Prometheus or an intermediate proxy) does not contain a Content-Type header identifying the payload as JSON, that is the media type from the response is not as expected.See CHANGELOG
See CHANGELOG
Content-Type: application/json; charset=utf-8 (see issue)See CHANGELOG
See CHANGELOG
InstantQueryBuilder::header and RangeQueryBuilder::header (see also PR #6, thank you @lasantosr)See CHANGELOG
See CHANGELOG
reqwest by the same name.Nothing published for this version
See CHANGELOG
See CHANGELOG
Client::is_server_healthyClient::is_server_readyurl to v2.3See CHANGELOG
See CHANGELOG
prometheus_http_query::error::ApiErrorType that corresponds to the error variants that are used within the Prometheus API code.prometheus_http_query::error::ApiError is now part of the public crate API and provides methods to inspect the cause of the error, e.g. ApiError::error_type, ApiError::is_timeout and ApiError::message.Client methods now return the proper error variant when e.g. a reverse proxy acts as intermediary. This considers the following three cases:
Result::Ok.ApiError containing the error details within Result::Err.reqwest::Error within Result::Err.See CHANGELOG
See CHANGELOG
Client methods now properly return prometheus_http_query::error::ApiError when Prometheus responds with an HTTP 4xx and the error type and message are captured.Have a look at the CHANGELOG
Have a look at the CHANGELOG
Client::query and Client::query_range now return builder types to add parameters to a request (e.g. timeout) before sending the request via InstantQueryBuilder::get or InstantQueryBuilder::post and their pendants in RangeQueryBuilder. The purpose is to reduce the number of parameters in e.g. Client::query and configure a request via a builder instead as the number of parameters will certainly increase in the future.InstantQueryBuilder::get, InstantQueryBuilder::post and their RangeQueryBuilder pendants still return a Result<PromqlResult, _>, but the Promqlresult now contains data and stats. The former being the familiar collection of vectors or matrices, the latter the execution stats as returned by the HTTP API.Client::base_url now returns UrlPromqlResult::as_instant -> Data::as_vectorPromqlResult::as_range -> Data::as_matrixPromqlResult::as_scalar -> Data::as_scalarInstantQueryBuilder and RangeQueryBuilder. Each allows to set additional optional parameters to a request (e.g. a timeout). Request can then be sent using HTTP GET (see InstantQueryBuilder::get) or POST (see InstantQueryBuilder::post).InstantQueryBuilder::stats and RangeQueryBuilder::stats as the first new query parameter/builder method. Use it to request query execution stats from Prometheus as part of the PromqlResult when get or post are executed. See this pull request for details and background information.PromqlResult::dataPromqlResult::statsNothing published for this version
## Added - Client::wal_replay_statistics - Client::tsdb_statistics
Client::wal_replay_statisticsClient::tsdb_statisticsQueryResultType -> PromqlResult
QueryResultType -> PromqlResult/api/v1/alertmanagers is now parsed as Alertmanagers { active: Vec<Alertmanager>, dropped: Vec<Alertmanager> }Selector::with -> Selector::eqSelector::without -> Selector::neSelector::regex_match -> Selector::regex_eqSelector::no_regex_match -> Selector::regex_neTarget.scrape_interval from String to time::DurationTarget.scrape_timeout from String to time::DurationClient::query: from query(&self, vector: impl Display, time: Option<i64>, timeout: Option<&str>) to query(&self, query: impl ToString, time: Option<i64>, timeout: Option<i64>)Client::query_range: from query_range(&self, vector: impl Display, start: i64, end: i64, step: &str, timeout: Option<&str>) to query_range(&self, query: impl ToString, start: i64, end: i64, step: f64, timeout: Option<i64>)Error::ResponseError -> Error::ApiErrorError::Reqwest -> Error::ClientAlertmanager that currently just wraps url::Url since this is the only item returned from the/api/v1/alertmanagers endpoint as yet.Client::build_information returning BuildInformationClient::runtime_information returning RuntimeInformationprometheus_http_query::queryprometheus_http_query::query_rangeprometheus_http_query::seriesprometheus_http_query::label_namesprometheus_http_query::label_valuesprometheus_http_query::targetsprometheus_http_query::rulesprometheus_http_query::flagsprometheus_http_query::alertmanagersprometheus_http_query::build_informationprometheus_http_query::runtime_informationprometheus_http_query::target_metadataprometheus_http_query::metric_metadatafunctions module, aggregations module, all Selector functionality that relates to gradual building of PromQL queries.Error enum## Added - #[derive(Clone)] on all types in the response module, see #2.
#[derive(Clone)] on all types in the response module, see #2.Aligned validation of time duration with the go implementation (e.g. the total value in nanoseconds must not exceed i64::MAX)
i64::MAX)Create a Client from a string literal via Client::from_str() or Client::try_from(), from a String via Client::try_from().
Client from a string literal via Client::from_str() or Client::try_from(), from a String via Client::try_from().QueryResultType::Scalar.Client::from() to create a Client from a custom-built reqwest::Client plus a base URL, so authentication, proxy settings etc. may be customized by the user.Selector::metric() is not fallible anymore. Metric names that equal reserved Prometheus keywords like "on" can now be queried.Client::new()Error::IllegalMetricNameprometheus_http_query::functions::scalar could not possibly return a result. An error would be thrown inevitably. The query result will now correctly be a QueryResultType::Scalar(Sample) that can be extracted by QueryResultType::as_scalar().## Added - Add Client::from(url: &str)
Client::from(url: &str)Implement Clone for Client so it does not need to be wrapped into Arc (the underlying reqwest::Client already uses Arc internally)
Clone for Client so it does not need to be wrapped into Arc (the underlying reqwest::Client already uses Arc internally)Debug and Display for Schemetime to v0.3.6Add present_over_time function available from Prometheus v2.29.0
time to v0.3present_over_time function available from Prometheus v2.29.0Client::targetsRename response::Group to response::RuleGroup
Response type.response::Group to response::RuleGroupClient::labels() -> Client::label_names()url::Url instead of String; Target::scrape_url() and Target::global_url() now return &Urlstime::OffsetDateTime instead of String; Target::last_scrape() and Alert::active_at() now return &OffsetDateTimesClient::query() and Client::query_range() now return a QueryResultType enum with Variants Vector and Matrix that encapsulate a vector of InstantVectors and RangeVectors respectively.Client methods' response types are not wrapped into Response anymore as the return type of these methods is fixed.error::UnsupportedResponseDataType to UnsupportedQueryResultType that is only thrown when a expression query result cannot be parsed as QueryResultType.Client::flags() to retrieve flags that Prometheus was configured with.Client::alertmanagers() to retrieve current alertmanager discovery status.Client::target_metadata() to retrieve metric metadata along with target information.Client::metric_metadata() to retrieve metric metadata.error::ResponseParse as generic wrapper around serde_json::Error.error::MissingField to avoid panics when API response (for whatever reason) does not contain documented and thus expected fields.Some convenience methods to retrieve the expected type of data from a QueryResultType:
QueryResultType.as_instant()QueryResultType.as_range()Add methods to Client to retrieve recording/alerting rules and active alerts
client.targets() method to retrieve currently active/dropped targets
Added methods to query metadata (series and labels)
Added methods to query metadata (series and labels)
Nothing published for this version
Nothing published for this version
One column per quarter.