From 79598c5a3787d74478b794eb75e4fe9ff2bd68fb Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 5 Jan 2024 16:35:50 +0900 Subject: [PATCH] out_prometheus_exporter: respond with 200 even with no metrics --- plugins/out_prometheus_exporter/prom_http.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/out_prometheus_exporter/prom_http.c b/plugins/out_prometheus_exporter/prom_http.c index 5f3307f9af0..e226790e0c9 100644 --- a/plugins/out_prometheus_exporter/prom_http.c +++ b/plugins/out_prometheus_exporter/prom_http.c @@ -163,17 +163,17 @@ static void cb_metrics(mk_request_t *request, void *data) struct prom_http_buf *buf; (void) data; + mk_http_status(request, 200); + flb_hs_add_content_type_to_req(request, FLB_HS_CONTENT_TYPE_PROMETHEUS); + buf = metrics_get_latest(); if (!buf) { - mk_http_status(request, 404); mk_http_done(request); return; } buf->users++; - mk_http_status(request, 200); - flb_hs_add_content_type_to_req(request, FLB_HS_CONTENT_TYPE_PROMETHEUS); mk_http_send(request, buf->buf_data, buf->buf_size, NULL); mk_http_done(request);