From 428ceb9c8771a597513923b1cc4dea03603cb970 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 4 Dec 2023 10:49:52 +0100 Subject: [PATCH] MINOR: promex: Export active/backup metrics per-server 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 | 2 ++ addons/promex/service-prometheus.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/promex/README b/addons/promex/README index 4e29e23ca..af14e41c7 100644 --- a/addons/promex/README +++ b/addons/promex/README @@ -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 | diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index 86782b1af..01408d298 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -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 */