From: Christopher Faulet Date: Fri, 15 Nov 2024 13:09:15 +0000 (+0100) Subject: MINOR: promex: Expose the global node and description in process metrics X-Git-Tag: v3.1-dev13~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=451d216a5330c7d891c079c728e9be0a1744b388;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/addons/promex/README b/addons/promex/README index 8c2266f69e..6eb2698d8b 100644 --- a/addons/promex/README +++ b/addons/promex/README @@ -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 | diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index 5d26733edd..78115aa5ce 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -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);