pub fn target_metadata(
    host: &str
) -> Result<TargetMetadataQueryBuilder<'_>, Error>
Expand description

Create a TargetMetadataQueryBuilder to apply filters to a target metadata query before sending it to Prometheus.

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

use prometheus_http_query::{target_metadata, Selector};

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

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

    Ok(())
}