Struct prometheus_http_query::Client[][src]

pub struct Client { /* fields omitted */ }
Expand description

A client used to execute queries. It uses a reqwest::Client internally that manages connections for us.

Implementations

Create a Client that connects to a Prometheus instance at the given FQDN/domain and port, using either HTTP or HTTPS.

Note that possible errors regarding domain name resolution or connection establishment will only be propagated from the underlying reqwest::Client when a query is executed.

use prometheus_http_query::{Client, Scheme};

let client = Client::new(Scheme::Http, "localhost", 9090);

Perform an instant query using a crate::RangeVector or crate::InstantVector.

use prometheus_http_query::{Client, Scheme, InstantVector, Selector, Aggregate};
use prometheus_http_query::aggregations::sum;
use std::convert::TryInto;

let client = Client::new(Scheme::Http, "localhost", 9090);

let v: InstantVector = Selector::new()
    .metric("cpu_seconds_total")
    .unwrap()
    .try_into()
    .unwrap();

let s = sum(v, Some(Aggregate::By(&["cpu"])));

let response = tokio_test::block_on( async { client.query(s, None, None).await });

assert!(response.is_ok());

Trait Implementations

Create a Client that connects to a local Prometheus instance at port 9090.

use prometheus_http_query::Client;

let client: Client = Default::default();

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.