prometheus-http-query
Prometheus HTTP API client
0.9.0
5.6M downloads/mo
#4315 most downloaded on crates.io
puetzp/prometheus-http-query
What this package is like to depend on
Last release 3 months ago
09 May 2026
Ships unpredictably
gaps range from 2 weeks to 2.1 years
Some releases are documented
notes for 14 of 29 stable releases
1 version withdrawn
withdrawn after publishing
5 years old
30 releases · first in 2021
1 release in the last 12 months
see the full history below
Release timeline
30 releases · Apr 2021 to May 2026Releases
latest 30-
0.9.009 May 2026Release notes
Open source →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.
Release notes
Open source →Added
- Re-export
reqwestto avoid having to manage multiple, possibly conflicting dependencies to the same crate in a user'sCargo.toml(thanks to @svcalex via pull request)
Changed
- Update
reqwestinCargo.tomlto0.13(thanks to @drbrain via pull request) - Also contains the unreleased changes of
0.8.4
- Re-export
-
0.8.308 Apr 2024Release notes
Open source →Changed
- Bumped dependency
reqwestto v12.x (@chris13524 via pull request) - Bumped dependency
urlto v2.5
- Bumped dependency
-
0.8.230 Dec 2023Release notes
Open source →Added
InstantQueryBuilder::queryRangeQueryBuilder::query
All changes by courtesy of @alesharik via pull request.
-
0.8.128 Dec 2023Release notes
Open source →Added
InstantQueryBuilder::get_rawInstantQueryBuilder::post_rawRangeQueryBuilder::get_rawRangeQueryBuilder::post_rawLabelNamesQueryBuilder::get_rawLabelValuesQueryBuilder::get_rawMetricMetadataQueryBuilder::get_rawRulesQueryBuilder::get_rawSeriesQueryBuilder::get_rawTargetMetadataQueryBuilder::get_raw
All changes by courtesy of @VoltaireNoir via pull request.
-
0.8.009 Dec 2023Release notes
Open source →Added
- Derive
CopyonSample Data::as_vector_mutData::as_matrix_mutData::as_scalar_mutData::into_vectorData::into_matrixData::into_samplePromqlResult::into_inner
Changed
Data::as_vectorreturnsOption<&Vec<InstantVector>>nowData::as_matrixreturnsOption<&Vec<RangeVector>>now
Note 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.
- Derive
-
0.7.129 Oct 2023 -
0.7.013 Oct 2023Release notes
Open source →Added
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()
Changed
Among other changes some
Clientmethods have been refactored and return "builders" (likeClient::queryandClient::query_rangealready 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 passNonea lot to use the "default" functionality of the given Prometheus API endpoint. The followingClientmethods were refactored in that fashion:Client::rules()Client::target_metadata()Client::metric_metadata()Client::series()Client::label_names()Client::label_values()
Other changes include:
- Renamed
RuleTypetoRuleKindand its variants fromAlertandRecordtoAlertingandRecording. Alert::value()now returns f64.Client::query,Client::query_rangedirect::queryanddirect::query_rangenow require the PromQl query string to implementstd::fmt::Displayinstead ofstd::string::ToString.- Refactored deserialization of Prometheus server responses so the explicit dependency on
serde_jsoncould be removed. - Refactored the
errormodule and some custom errors related to deserialization usingserde::de::Error. TheErrorenum inside theerrormodule now contains one variant less and existing error variants were improved by properly implementingstd::error::Error::source(). Libraries likeanyhoware now able to display more detailed error messages. This change is not breaking if you did not match on specific error enum variants before. Clientmethods now return a more concise error if the server response (from Prometheus or an intermediate proxy) does not contain aContent-Typeheader identifying the payload as JSON, that is the media type from the response is not as expected.
-
0.6.730 Sep 2023Release notes
Open source →Fixed
- Fixes an issue where a Prometheus server sends an HTTP response with
Content-Type: application/json; charset=utf-8(see issue)
- Fixes an issue where a Prometheus server sends an HTTP response with
-
0.6.617 Apr 2023Release notes
Open source →Added
InstantQueryBuilder::headerandRangeQueryBuilder::header(see also PR #6, thank you @lasantosr)
-
0.6.527 Jan 2023Release notes
Open source →Added
- Added several feature flags pertaining to the client TLS configuration that match the feature flags of
reqwestby the same name.
- Added several feature flags pertaining to the client TLS configuration that match the feature flags of
-
0.6.426 Jan 2023 withdrawnNothing published for this version
-
0.6.320 Nov 2022Release notes
Open source →Added
Client::is_server_healthyClient::is_server_ready
Changed
- Update crate
urlto v2.3
-
0.6.223 Aug 2022Release notes
Open source →Added
prometheus_http_query::error::ApiErrorTypethat corresponds to the error variants that are used within the Prometheus API code.
Changed
prometheus_http_query::error::ApiErroris now part of the public crate API and provides methods to inspect the cause of the error, e.g.ApiError::error_type,ApiError::is_timeoutandApiError::message.
Fixed
Clientmethods now return the proper error variant when e.g. a reverse proxy acts as intermediary. This considers the following three cases:- Prometheus returns 2xx with JSON body -> JSON is parsed and function returns the result in a
Result::Ok. - Prometheus returns 4xx or 5xx -> JSON is parsed and function returns the
ApiErrorcontaining the error details withinResult::Err. - A proxy cannot handle the request and responds with a 4xx or 5xx itself -> error is raised and function returns the wrapped
reqwest::ErrorwithinResult::Err.
- Prometheus returns 2xx with JSON body -> JSON is parsed and function returns the result in a
-
0.6.122 Aug 2022Release notes
Open source →Fixed
- All
Clientmethods now properly returnprometheus_http_query::error::ApiErrorwhen Prometheus responds with an HTTP 4xx and the error type and message are captured.
Changed
- Simplified JSON body parsing with serde (no API changes).
- All
-
0.6.001 Aug 2022Release notes
Open source →Changed
Client::queryandClient::query_rangenow return builder types to add parameters to a request (e.g.timeout) before sending the request viaInstantQueryBuilder::getorInstantQueryBuilder::postand their pendants inRangeQueryBuilder. The purpose is to reduce the number of parameters in e.g.Client::queryand configure a request via a builder instead as the number of parameters will certainly increase in the future.InstantQueryBuilder::get,InstantQueryBuilder::postand theirRangeQueryBuilderpendants still return aResult<PromqlResult, _>, but the Promqlresult now containsdataandstats. The former being the familiar collection of vectors or matrices, the latter the execution stats as returned by the HTTP API.Client::base_urlnow returnsUrl- Move and rename
PromqlResult::as_instant->Data::as_vector - Move and rename
PromqlResult::as_range->Data::as_matrix - Move
PromqlResult::as_scalar->Data::as_scalar
Added
InstantQueryBuilderandRangeQueryBuilder. Each allows to set additional optional parameters to a request (e.g. atimeout). Request can then be sent using HTTP GET (seeInstantQueryBuilder::get) or POST (seeInstantQueryBuilder::post).InstantQueryBuilder::statsandRangeQueryBuilder::statsas the first new query parameter/builder method. Use it to request query execution stats from Prometheus as part of thePromqlResultwhengetorpostare executed. See this pull request for details and background information.PromqlResult::dataPromqlResult::stats
-
0.5.206 Jul 2022Nothing published for this version
-
0.5.129 Mar 2022Nothing published for this version
-
0.5.027 Mar 2022Nothing published for this version
-
0.4.218 Mar 2022Nothing published for this version
-
0.4.116 Mar 2022Nothing published for this version
-
0.4.009 Feb 2022Nothing published for this version
-
0.3.324 Jan 2022Nothing published for this version
-
0.3.222 Jan 2022Nothing published for this version
-
0.3.130 Dec 2021Nothing published for this version
-
0.3.010 Jul 2021Nothing published for this version
-
0.2.319 Jun 2021Nothing published for this version
-
0.2.218 Jun 2021Nothing published for this version
-
0.2.117 Jun 2021Nothing published for this version
-
0.2.017 Jun 2021Nothing published for this version
-
0.1.014 Apr 2021Nothing published for this version