]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: add server revision id support
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 17 Nov 2022 15:34:07 +0000 (16:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Dec 2022 09:22:06 +0000 (10:22 +0100)
Make use of the new srv->rid value in stats.

Stat is referred as ST_F_SRID, it is now used in stats_fill_sv_stats
function in order to be included in csv and json stats dumps.

Moreover, "rid: $value" will be displayed next to server puid
in html stats page if "stats show-legend" is specified in the stats frontend.
(mouse hovering tooltip)

Depends on the following commit:
"MINOR: server: add srv->rid (revision id) value"

include/haproxy/stats-t.h
src/stats.c

index efa0ac3839d917a2d90d5597ecad9749d37b2d2e..1a7d3d157d83f00da96bcac028993159d3cff4dc 100644 (file)
@@ -456,6 +456,7 @@ enum stat_field {
        ST_F_NEED_CONN_EST,
        ST_F_UWEIGHT,
        ST_F_AGG_SRV_CHECK_STATUS,
+       ST_F_SRID,
 
        /* must always be the last one */
        ST_F_TOTAL_FIELDS
index 8ed5a7133838a5a7ecf810dbb2b4473ddf2be347..5fd4d3f969a0294ed3eba36a099d18b5067fd121 100644 (file)
@@ -260,6 +260,7 @@ const struct name_desc stat_fields[ST_F_TOTAL_FIELDS] = {
        [ST_F_NEED_CONN_EST]                 = { .name = "need_conn_est",               .desc = "Estimated needed number of connections"},
        [ST_F_UWEIGHT]                       = { .name = "uweight",                     .desc = "Server's user weight, or sum of active servers' user weights for a backend" },
        [ST_F_AGG_SRV_CHECK_STATUS]          = { .name = "agg_server_check_status",     .desc = "Backend's aggregated gauge of servers' state check status" },
+       [ST_F_SRID]                          = { .name = "srid",                        .desc = "Server id revision, to prevent server id reuse mixups" },
 };
 
 /* one line of info */
@@ -1153,7 +1154,7 @@ static int stats_dump_fields_html(struct buffer *out,
                                chunk_appendf(out, "%s, ", field_str(stats, ST_F_ADDR));
 
                        /* id */
-                       chunk_appendf(out, "id: %d", stats[ST_F_SID].u.u32);
+                       chunk_appendf(out, "id: %d, rid: %d", stats[ST_F_SID].u.u32, stats[ST_F_SRID].u.u32);
 
                        /* cookie */
                        if (stats[ST_F_COOKIE].type) {
@@ -2283,6 +2284,9 @@ int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
                        case ST_F_SID:
                                metric = mkf_u32(FO_KEY|FS_SERVICE, sv->puid);
                                break;
+                       case ST_F_SRID:
+                               metric = mkf_u32(FN_COUNTER, sv->rid);
+                               break;
                        case ST_F_THROTTLE:
                                if (sv->cur_state == SRV_ST_STARTING && !server_is_draining(sv))
                                        metric = mkf_u32(FN_AVG, server_throttle_rate(sv));