]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: contrib/prometheus-exporter: Add missing label for ST_F_HRSP_1XX
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 1 Feb 2021 13:55:37 +0000 (14:55 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 1 Feb 2021 14:16:33 +0000 (15:16 +0100)
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

index 8674cf33edc87c6cda920b8a51af03b80e800b52..4ee223ac70cda780f870a8bac8c05666f25a7616 100644 (file)
@@ -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];