Skip to content

Commit d1adfd9

Browse files
committed
BUG/MEDIUM: promex: Fix dump of extra counters
When extra counters are dumped for an entity (frontend, backend, server or listener), there is a filter on capabilities. Some extra counters are not available for all entities and must be ignored. However, when this was performed, the field number, used as an index to dump the metric value, was still incremented while it should not and leads to an overflow or a stats mix-up. This patch must be backported to 3.0.
1 parent e75a019 commit d1adfd9

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

addons/promex/service-prometheus.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,8 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
726726
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
727727
void *counters;
728728

729-
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE)) {
730-
ctx->field_num += mod->stats_count;
731-
ctx->mod_field_num = 0;
729+
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE))
732730
continue;
733-
}
734731

735732
for (;ctx->mod_field_num < mod->stats_count; ctx->mod_field_num++) {
736733
name = ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name));
@@ -898,11 +895,8 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
898895
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
899896
void *counters;
900897

901-
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI)) {
902-
ctx->field_num += mod->stats_count;
903-
ctx->mod_field_num = 0;
898+
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI))
904899
continue;
905-
}
906900

907901
for (;ctx->mod_field_num < mod->stats_count; ctx->mod_field_num++) {
908902
name = ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name));
@@ -1179,11 +1173,8 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
11791173
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
11801174
void *counters;
11811175

1182-
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE)) {
1183-
ctx->field_num += mod->stats_count;
1184-
ctx->mod_field_num = 0;
1176+
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE))
11851177
continue;
1186-
}
11871178

11881179
for (;ctx->mod_field_num < mod->stats_count; ctx->mod_field_num++) {
11891180
name = ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name));
@@ -1437,11 +1428,8 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
14371428
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
14381429
void *counters;
14391430

1440-
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV)) {
1441-
ctx->field_num += mod->stats_count;
1442-
ctx->mod_field_num = 0;
1431+
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV))
14431432
continue;
1444-
}
14451433

14461434
for (;ctx->mod_field_num < mod->stats_count; ctx->mod_field_num++) {
14471435
name = ist2(mod->stats[ctx->mod_field_num].name, strlen(mod->stats[ctx->mod_field_num].name));

0 commit comments

Comments
 (0)