Crate prometheus_http_client

Crate prometheus_http_client 

Source
Expand description

Minimal API for getting time series data from prometheus, and making small plots.

To use it, instantiate one of the request objects, e.g. QueryRequest or QueryRangeRequest. When it’s helpful a builder is provided.

Then use PromRequest trait and call send or send_with_client. This takes the prometheus url, and optionally a reqwest client to use.

On success, the result is PromData. One would usually call into_matrix()? or into_vector()? as expected for the request that is made.

In prometheus, metric labels are just a set of key-value pairs. However, if you are expecting certain structure, you may use any KV object that implements serde::Deserialize in the PromData that results from the call.

When plot feature is active, the plot module can be used to plot the timeseries data. This was designed to be used to generate previews in alert messages.

Modules§

plot
Make a simple plot of time-series data from prometheus

Structs§

AlertInfo
Information about a single alert
AlertsRequest
Query parameters for /api/v1/alerts prometheus request
AlertsResponse
Response from /api/v1/alerts endpoint
ExtractLabels
Common labels extracted from a very generic sequence of metric labels (key value pairs)
LabelsRequest
Query parameters for /api/v1/labels prometheus request
MatchList
Represents a sequence of match[]=…,match[]=… query parameters required by parts of prometheus api
MetricTimeseries
A metric timeseries from a range query
MetricVal
Wrapper for f64 that deserializes from a string (prometheus returns numeric values as strings)
MetricValue
A single metric value from an instant query
QueryRangeRequest
Query parameters for /api/v1/query_range prometheus request Use builder to populate it
QueryRangeRequestBuilder
Builder for constructing a QueryRangeRequest
QueryRequest
Query parameters for /api/v1/query prometheus request
ReqwestClient
An asynchronous Client to make Requests with.
SeriesRequest
Query parameters for /api/v1/series prometheus request

Enums§

AlertStatus
The state of an alert
Error
Errors that can occur when making Prometheus API requests
PromData
The data payload from a Prometheus query response

Traits§

PromRequest
Trait for types that can be sent as Prometheus API requests

Type Aliases§

Labels
A set of labels extracted by ExtractLabels