MINOR: promex: Expose the global node and description in process metrics

The global node value is now exposed via "haproxy_process_node" metrics. The
metric value is always set to 1 and the node name itself is the "node"
label. The same is performed for the global description. But only if it is
defined. In that case "haproxy_process_description" metric is defined, with
1 as value and the description itself is set in the "desc" label.
This commit is contained in:
Christopher Faulet 2024-11-15 14:09:15 +01:00
parent a930e99f46
commit 451d216a53
2 changed files with 18 additions and 2 deletions

View File

@ -193,6 +193,8 @@ listed below. Metrics from extra counters are not listed.
| haproxy_process_current_tasks |
| haproxy_process_current_run_queue |
| haproxy_process_idle_time_percent |
| haproxy_process_node |
| haproxy_process_description |
| haproxy_process_stopping |
| haproxy_process_jobs |
| haproxy_process_unstoppable_jobs |

View File

@ -153,8 +153,8 @@ const struct promex_metric promex_global_metrics[ST_I_INF_MAX] = {
[ST_I_INF_TASKS] = { .n = IST("current_tasks"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_RUN_QUEUE] = { .n = IST("current_run_queue"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_IDLE_PCT] = { .n = IST("idle_time_percent"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
//[ST_I_INF_NODE] ignored
//[ST_I_INF_DESCRIPTION] ignored
[ST_I_INF_NODE] = { .n = IST("node"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_DESCRIPTION] = { .n = IST("description"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_STOPPING] = { .n = IST("stopping"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_JOBS] = { .n = IST("jobs"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
[ST_I_INF_UNSTOPPABLE_JOBS] = { .n = IST("unstoppable_jobs"), .type = PROMEX_MT_GAUGE, .flags = PROMEX_FL_INFO_METRIC },
@ -580,6 +580,20 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
continue;
switch (ctx->field_num) {
case ST_I_INF_NODE:
labels[0].name = ist("node");
labels[0].value = ist(global.node);
val = mkf_u32(FN_GAUGE, 1);
break;
case ST_I_INF_DESCRIPTION:
if (!global.desc)
continue;
labels[0].name = ist("desc");
labels[0].value = ist(global.desc);
val = mkf_u32(FN_GAUGE, 1);
break;
case ST_I_INF_BUILD_INFO:
labels[0].name = ist("version");
labels[0].value = ist(HAPROXY_VERSION);