All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Samples::total_queryable_samples_per_step
now returnsOption<&Vec<SamplesPerStep>>
instead ofOption<&Vec<Sample>>
. The new typeSamplesPerStep
better describes what is measured by this query statistic. It also enables more efficient deserialization ofSample
.
- Bumped dependency
reqwest
to v12.x (@chris13524 via pull request) - Bumped dependency
url
to v2.5
InstantQueryBuilder::query
RangeQueryBuilder::query
All changes by courtesy of @alesharik via pull request.
InstantQueryBuilder::get_raw
InstantQueryBuilder::post_raw
RangeQueryBuilder::get_raw
RangeQueryBuilder::post_raw
LabelNamesQueryBuilder::get_raw
LabelValuesQueryBuilder::get_raw
MetricMetadataQueryBuilder::get_raw
RulesQueryBuilder::get_raw
SeriesQueryBuilder::get_raw
TargetMetadataQueryBuilder::get_raw
All changes by courtesy of @VoltaireNoir via pull request.
- Derive
Copy
onSample
Data::as_vector_mut
Data::as_matrix_mut
Data::as_scalar_mut
Data::into_vector
Data::into_matrix
Data::into_sample
PromqlResult::into_inner
Data::as_vector
returnsOption<&Vec<InstantVector>>
nowData::as_matrix
returnsOption<&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.
ClientError::inner()
ParseUrlError::inner()
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 RuleHealth
RuleHealth::is_good()
RuleHealth::is_bad()
RuleHealth::is_unknown()
impl Eq for AlertState
AlertState::is_inactive()
AlertState::is_pending()
AlertState::is_firing()
impl Eq for TargetHealth
TargetHealth::is_up()
TargetHealth::is_down()
TargetHealth::is_unknown()
impl Eq for MetricType
MetricType::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 WalReplayState
WalReplayState::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:
- Renamed
RuleType
toRuleKind
and its variants fromAlert
andRecord
toAlerting
andRecording
. Alert::value()
now returns f64.Client::query
,Client::query_range
direct::query
anddirect::query_range
now require the PromQl query string to implementstd::fmt::Display
instead ofstd::string::ToString
.- Refactored deserialization of Prometheus server responses so the explicit dependency on
serde_json
could be removed. - Refactored the
error
module and some custom errors related to deserialization usingserde::de::Error
. TheError
enum inside theerror
module now contains one variant less and existing error variants were improved by properly implementingstd::error::Error::source()
. Libraries likeanyhow
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 aContent-Type
header identifying the payload as JSON, that is the media type from the response is not as expected.
- Fixes an issue where a Prometheus server sends an HTTP response with
Content-Type: application/json; charset=utf-8
(see issue)
InstantQueryBuilder::header
andRangeQueryBuilder::header
(see also PR #6, thank you @lasantosr)
- Added several feature flags pertaining to the client TLS configuration that match the feature flags of
reqwest
by the same name.
Client::is_server_healthy
Client::is_server_ready
- Update crate
url
to v2.3
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
andApiError::message
.
Client
methods 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
ApiError
containing 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::Error
withinResult::Err
.
- Prometheus returns 2xx with JSON body -> JSON is parsed and function returns the result in a
- All
Client
methods now properly returnprometheus_http_query::error::ApiError
when Prometheus responds with an HTTP 4xx and the error type and message are captured.
- Simplified JSON body parsing with serde (no API changes).
Client::query
andClient::query_range
now return builder types to add parameters to a request (e.g.timeout
) before sending the request viaInstantQueryBuilder::get
orInstantQueryBuilder::post
and their pendants inRangeQueryBuilder
. 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 theirRangeQueryBuilder
pendants still return aResult<PromqlResult, _>
, but the Promqlresult now containsdata
andstats
. 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 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
InstantQueryBuilder
andRangeQueryBuilder
. 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::stats
andRangeQueryBuilder::stats
as the first new query parameter/builder method. Use it to request query execution stats from Prometheus as part of thePromqlResult
whenget
orpost
are executed. See this pull request for details and background information.PromqlResult::data
PromqlResult::stats