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
| 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
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++;