]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: promex: properly use alt_name and val instead of hard-coded values
authorWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2026 11:59:34 +0000 (13:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2026 16:00:51 +0000 (18:00 +0200)
Some string-based info from the "show info" output are returned as gauges
in promex, and the way it's done consists in forcing their label's name
and value to the desired name and values, then faking a value of 1 on the
gauge. Since 3.2 with commit b03e05cd36 ("MINOR: stats: add alt name info
to stat_cols_info where relevant"), this label's name appears in the stats
info's alt_name field. Thus there's no need to hard-code it again in the
promex code. Let's first do this for the "node" label.

addons/promex/service-prometheus.c

index d655c4345017153dc5be569f3ec193ade5a99130..76ea9a7a7954f22fbd502a7b28d84bd6bdd4c23e 100644 (file)
@@ -460,8 +460,8 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
 
                switch (ctx->field_num) {
                        case ST_I_INF_NODE:
-                               labels[lb_idx].name  = ist("node");
-                               labels[lb_idx].value = ist(global.node);
+                               labels[lb_idx].name  = name;
+                               labels[lb_idx].value = ist(field_str(&val, 0));
                                lb_idx++;
                                val = mkf_u32(FN_GAUGE, 1);
                                break;