Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add https support in Prometheus gateway #392

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading