Skip to content

Commit 757dcac

Browse files
authored
Specific endpoint for prometheus exporter health checking (#435)
1 parent 7e41a84 commit 757dcac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

metrics-exporter-prometheus/src/builder.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,15 @@ impl PrometheusBuilder {
435435
let handle = handle.clone();
436436

437437
async move {
438-
Ok::<_, hyper::Error>(service_fn(move |_| {
438+
Ok::<_, hyper::Error>(service_fn(move |req| {
439439
let handle = handle.clone();
440440

441441
async move {
442442
if is_allowed {
443-
let output = handle.render();
444-
Ok::<_, hyper::Error>(Response::new(Body::from(output)))
443+
Ok::<_, hyper::Error>(match req.uri().path() {
444+
"/health" => Response::new(Body::from("OK")),
445+
_ => Response::new(Body::from(handle.render())),
446+
})
445447
} else {
446448
Ok::<_, hyper::Error>(
447449
Response::builder()

0 commit comments

Comments
 (0)