From: Willy Tarreau Date: Tue, 15 Sep 2026 11:50:32 +0000 (+0200) Subject: MINOR: promex: expose the master and worker IDs as labels X-Git-Tag: v3.5-dev7~7 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=6da13fe8858006e42ac28c0bf879863c56679967;p=haproxy.git MINOR: promex: expose the master and worker IDs as labels This adds support for emitting the master id when defined (when master is running) and the worker id. Note that we add a check for the value being a non-empty string, which remains valid for the few other field that is always defined (node), so no impact on existing fields. The output looks like this: $ curl -s 0:8181/metrics?metrics=haproxy_process_master_id,haproxy_process_worker_id haproxy_process_master_id{master_id="..."} 1 haproxy_process_worker_id{worker_id="..."} 1 --- diff --git a/addons/promex/README b/addons/promex/README index 978052ec8..5da7cefc2 100644 --- a/addons/promex/README +++ b/addons/promex/README @@ -225,6 +225,8 @@ listed below. Metrics from extra counters are not listed. | haproxy_process_pool_allocated_bytes | | haproxy_process_pool_used_bytes | | haproxy_process_start_time_seconds | +| haproxy_process_master_id | +| haproxy_process_worker_id | +------------------------------------------------+ * Frontend metrics diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index 76ea9a7a7..6b302ab3d 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -460,6 +460,10 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx) switch (ctx->field_num) { case ST_I_INF_NODE: + case ST_I_INF_MASTER_ID: + case ST_I_INF_WORKER_ID: + if (field_format(&val, 0) != FF_STR || !val.u.str) + continue; labels[lb_idx].name = name; labels[lb_idx].value = ist(field_str(&val, 0)); lb_idx++;