Skip to content

Commit

Permalink
add https support in Prometheus gateway (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qingwen Zhao authored Sep 21, 2023
1 parent 0193688 commit d817f5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion metrics-exporter-prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ keywords = ["metrics", "telemetry", "prometheus"]
default = ["http-listener", "push-gateway"]
async-runtime = ["tokio", "hyper"]
http-listener = ["async-runtime", "hyper/server", "ipnet"]
push-gateway = ["async-runtime", "hyper/client", "tracing"]
push-gateway = ["async-runtime", "hyper/client", "hyper-tls", "tracing"]

[dependencies]
metrics = { version = "^0.21", path = "../metrics" }
Expand All @@ -35,6 +35,7 @@ hyper = { version = "0.14", default-features = false, features = ["tcp", "http1"
ipnet = { version = "2", optional = true }
tokio = { version = "1", features = ["rt", "net", "time"], optional = true }
tracing = { version = "0.1.26", optional = true }
hyper-tls = { version = "0.5.0", optional = true }

[dev-dependencies]
tracing = "0.1"
Expand Down
4 changes: 3 additions & 1 deletion metrics-exporter-prometheus/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use hyper::{
http::HeaderValue,
Method, Request, Uri,
};
use hyper_tls::HttpsConnector;

use indexmap::IndexMap;
#[cfg(feature = "http-listener")]
Expand Down Expand Up @@ -460,7 +461,8 @@ impl PrometheusBuilder {
#[cfg(feature = "push-gateway")]
ExporterConfig::PushGateway { endpoint, interval, username, password } => {
let exporter = async move {
let client = Client::new();
let https = HttpsConnector::new();
let client = Client::builder().build::<_, hyper::Body>(https);
let auth = username.as_ref().map(|name| basic_auth(name, password.as_deref()));

loop {
Expand Down

0 comments on commit d817f5c

Please sign in to comment.