]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: promex: Export active/backup metrics per-server
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 Dec 2023 09:49:52 +0000 (10:49 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Dec 2023 09:24:41 +0000 (10:24 +0100)
numbers of active and backup servers per backend were exported but the info
was not exported per-server. The main issue to do so was we were unable to
have a different name for the same metric in a different scope. Thanks to
the previous patch ("MINOR: promex: Add support for specialized
front/back/li/srv metric names") it is now possible. So the info is now
exported per-server.

This patch should fix the issue #2271.

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

index 4e29e23cab4c046adeceb4703c8749d2ca4b37b2..af14e41c794c1f5d44cccf3dfbe4c3be4c6cb178 100644 (file)
@@ -310,6 +310,8 @@ See prometheus export for the description of each field.
 | haproxy_server_redispatch_warnings_total           |
 | haproxy_server_status                              |
 | haproxy_server_weight                              |
+| haproxy_server_active                              |
+| haproxy_server_backup                              |
 | haproxy_server_check_failures_total                |
 | haproxy_server_check_up_down_total                 |
 | haproxy_server_check_last_change_seconds           |
index 86782b1af9edd14c931b611e17ff0e954f7d7b30..01408d2982416fa3413795af73e8e2ae8bc15b85 100644 (file)
@@ -220,8 +220,8 @@ const struct promex_metric promex_st_metrics[ST_F_TOTAL_FIELDS] = {
        [ST_F_WREDIS]               = { .n = IST("redispatch_warnings_total"),        .type = PROMEX_MT_COUNTER,  .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
        [ST_F_STATUS]               = { .n = IST("status"),                           .type = PROMEX_MT_GAUGE,    .flags = (PROMEX_FL_FRONT_METRIC | PROMEX_FL_LI_METRIC | PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
        [ST_F_WEIGHT]               = { .n = IST("weight"),                           .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
-       [ST_F_ACT]                  = { .n = IST("active_servers"),                   .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC                       ) },
-       [ST_F_BCK]                  = { .n = IST("backup_servers"),                   .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC                       ) },
+       [ST_F_ACT]                  = { .n = IST("active_servers"),                   .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
+       [ST_F_BCK]                  = { .n = IST("backup_servers"),                   .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
        [ST_F_CHKFAIL]              = { .n = IST("check_failures_total"),             .type = PROMEX_MT_COUNTER,  .flags = (                                                                       PROMEX_FL_SRV_METRIC) },
        [ST_F_CHKDOWN]              = { .n = IST("check_up_down_total"),              .type = PROMEX_MT_COUNTER,  .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
        [ST_F_LASTCHG]              = { .n = IST("check_last_change_seconds"),        .type = PROMEX_MT_GAUGE,    .flags = (                                               PROMEX_FL_BACK_METRIC | PROMEX_FL_SRV_METRIC) },
@@ -320,6 +320,8 @@ const struct ist promex_st_li_metrics_names[ST_F_TOTAL_FIELDS] = {
 
 /* Specialized server metric names, to override default ones */
 const struct ist promex_st_srv_metrics_names[ST_F_TOTAL_FIELDS] = {
+       [ST_F_ACT] = IST("active"),
+       [ST_F_BCK] = IST("backup"),
 };
 
 /* Description of overridden stats fields */