]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: promex: Expose the global node and description in process metrics
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Nov 2024 13:09:15 +0000 (14:09 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Nov 2024 13:24:31 +0000 (14:24 +0100)
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.

addons/promex/README
addons/promex/service-prometheus.c

index 8c2266f69eac5ad765b395c982d7da3423e2e40e..6eb2698d8b13ff43958d37fa9291b5b3d451e58b 100644 (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               |
index 5d26733edd288e9977896869138dbdbab200d070..78115aa5ce9b2d5d77a67a8af47b97e09f00f191 100644 (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);