From 32ef48e984deb96ff20b8cb6c98311e41cadb772 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 1 Feb 2021 14:55:37 +0100 Subject: [PATCH] BUG/MINOR: contrib/prometheus-exporter: Add missing label for ST_F_HRSP_1XX Since the labels are dynamically created for each metric, the "code" label of the ST_F_HRSP_1XX field is missing. To fix the bug, this metric is handled in the same way the other ST_F_HRSP_* field are. We only take care to dump the metric header only once. This bug was introduced by the commit 5a2f93873 ("MEDIUM: contrib/prometheus-exporter: Use dynamic labels instead of static ones"). No backport needed. --- contrib/prometheus-exporter/service-prometheus.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index 8674cf33e..4ee223ac7 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -639,7 +639,6 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) goto next_px; case ST_F_REQ_RATE_MAX: case ST_F_REQ_TOT: - case ST_F_HRSP_1XX: case ST_F_INTERCEPTED: case ST_F_CACHE_LOOKUPS: case ST_F_CACHE_HITS: @@ -651,6 +650,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) goto next_px; val = stats[appctx->st2]; break; + case ST_F_HRSP_1XX: case ST_F_HRSP_2XX: case ST_F_HRSP_3XX: case ST_F_HRSP_4XX: @@ -658,7 +658,8 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) case ST_F_HRSP_OTHER: if (px->mode != PR_MODE_HTTP) goto next_px; - appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; + if (appctx->st2 != ST_F_HRSP_1XX) + appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; labels[1].name = ist("code"); labels[1].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX]; val = stats[appctx->st2]; @@ -770,7 +771,6 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) val = mkf_flt(FN_MAX, secs); break; case ST_F_REQ_TOT: - case ST_F_HRSP_1XX: case ST_F_CACHE_LOOKUPS: case ST_F_CACHE_HITS: case ST_F_COMP_IN: @@ -781,6 +781,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) goto next_px; val = stats[appctx->st2]; break; + case ST_F_HRSP_1XX: case ST_F_HRSP_2XX: case ST_F_HRSP_3XX: case ST_F_HRSP_4XX: @@ -788,7 +789,8 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) case ST_F_HRSP_OTHER: if (px->mode != PR_MODE_HTTP) goto next_px; - appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; + if (appctx->st2 != ST_F_HRSP_1XX) + appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; labels[1].name = ist("code"); labels[1].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX]; val = stats[appctx->st2]; @@ -938,11 +940,11 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) val = mkf_flt(FN_DURATION, secs); break; case ST_F_REQ_TOT: - case ST_F_HRSP_1XX: if (px->mode != PR_MODE_HTTP) goto next_px; val = stats[appctx->st2]; break; + case ST_F_HRSP_1XX: case ST_F_HRSP_2XX: case ST_F_HRSP_3XX: case ST_F_HRSP_4XX: @@ -950,7 +952,8 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) case ST_F_HRSP_OTHER: if (px->mode != PR_MODE_HTTP) goto next_px; - appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; + if (appctx->st2 != ST_F_HRSP_1XX) + appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR; labels[2].name = ist("code"); labels[2].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX]; val = stats[appctx->st2];