pub async fn target_metadata(
    host: &str,
    metric: Option<&str>,
    match_target: Option<&Selector<'_>>,
    limit: Option<usize>
) -> Result<Vec<TargetMetadata>, Error>
Expand description

Retrieve metadata about metrics that are currently scraped from targets, along with target information.

This is just a convenience function for one-off requests, see Client::target_metadata.

use prometheus_http_query::{target_metadata, Error, Selector};

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Error> {
    let response = target_metadata("http://localhost:9090", Some("go_routines"), None, None).await;
    assert!(response.is_ok());

    let select = Selector::new().eq("job", "prometheus");
    let response = target_metadata("http://localhost:9090", None, Some(&select), None).await;
    assert!(response.is_ok());

    Ok(())
}