]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: implement bc_{be,srv}_queue samples
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 7 Feb 2024 09:55:22 +0000 (10:55 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 8 Feb 2024 08:39:23 +0000 (09:39 +0100)
%[bc_be_queue] and %[bc_srv_queue] are equivalent to %bq and %sq tags in
log-format.

doc/configuration.txt
src/sample.c

index f6ee5546158922af68b7536671b713a21ee989e2..9f0aa724b5d8cc84d98d85a62d242421130f50f4 100644 (file)
@@ -21025,6 +21025,7 @@ Summary of sample fetch methods in this section and their respective types:
 -------------------------------------------------+-------------
 accept_date([<unit>])                              integer
 bc.timer.connect                                   integer
+bc_be_queue                                        integer
 bc_dst                                             ip
 bc_dst_port                                        integer
 bc_err                                             integer
@@ -21033,6 +21034,7 @@ bc_glitches                                        integer
 bc_http_major                                      integer
 bc_src                                             ip
 bc_src_port                                        integer
+bc_srv_queue                                       integer
 be_id                                              integer
 be_name                                            string
 bc_rtt(<unit>)                                     integer
@@ -21251,6 +21253,10 @@ bc.timer.connect : integer
   equivalent of %Tc in the log-format. This is reported in milliseconds (ms).
   For more information see Section 8.4 "Timing events"
 
+bc_be_queue : integer
+  Number of streams de-queued while waiting for a connection slot on the
+  target backend. This is the equivalent of %bq in the log-format.
+
 bc_dst : ip
   This is the destination ip address of the connection on the server side,
   which is the server address HAProxy connected to. It is of type IP and works
@@ -21301,6 +21307,10 @@ bc_src_port : integer
   Returns an integer value corresponding to the TCP source port of the
   connection on the server side, which is the port HAProxy connected from.
 
+bc_srv_queue : integer
+  Number of streams de-queued while waiting for a connection slot on the
+  target server. This is the equivalent of %sq in the log-format.
+
 be_id : integer
   Returns an integer containing the current backend's id. It can be used in
   frontends with responses to check which backend processed the request. If
@@ -25400,6 +25410,7 @@ Please refer to the table below for currently defined variables :
   |   |      | %[bc_src_port]                                       | numeric |
   +---+------+------------------------------------------------------+---------+
   |   | %bq  | backend_queue                                        | numeric |
+  |   |      | %[bc_be_queue]                                       |         |
   +---+------+------------------------------------------------------+---------+
   |   | %ci  | client_ip                 (accepted address)         |         |
   |   |      | %[src]                                               | IP      |
@@ -25456,6 +25467,7 @@ Please refer to the table below for currently defined variables :
   |   |      | %[bc_dst_port]                                       | numeric |
   +---+------+------------------------------------------------------+---------+
   |   | %sq  | srv_queue                                            | numeric |
+  |   |      | %[bc_srv_queue]                                      |         |
   +---+------+------------------------------------------------------+---------+
   | S | %sslc| ssl_ciphers (ex: AES-SHA)                            |         |
   |   |      | %[ssl_fc_cipher]                                     | string  |
index 89de612b3cc5346155970690e527c86695505045..a7b8a23a7950866c290e18a14be69777008af45f 100644 (file)
@@ -4915,6 +4915,30 @@ error:
        return 0;
 }
 
+/* Server conn queueing infos - bc_{be,srv}_queue */
+static int smp_fetch_conn_queues(const struct arg *args, struct sample *smp, const char *kw, void *private)
+{
+       struct strm_logs *logs;
+
+       if (!smp->strm)
+               return 0;
+
+       smp->data.type = SMP_T_SINT;
+       smp->flags = 0;
+
+       logs = &smp->strm->logs;
+
+       if (kw[3] == 'b') {
+               /* bc_be_queue */
+               smp->data.u.sint = logs->prx_queue_pos;
+       }
+       else {
+               /* bc_srv_queue */
+               smp->data.u.sint = logs->srv_queue_pos;
+       }
+       return 1;
+}
+
 /* Timing events {f,bc}.timer.  */
 static int smp_fetch_conn_timers(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
@@ -5029,6 +5053,9 @@ static struct sample_fetch_kw_list smp_logs_kws = {ILH, {
        { "txn.timer.user",       smp_fetch_txn_timers,   0,         NULL, SMP_T_SINT, SMP_USE_TXFIN }, /* "Tu" */
 
        { "bc.timer.connect",     smp_fetch_conn_timers,  0,         NULL, SMP_T_SINT, SMP_USE_L4SRV }, /* "Tc" */
+       { "bc_be_queue",          smp_fetch_conn_queues,  0,         NULL, SMP_T_SINT, SMP_USE_L4SRV }, /* "bq" */
+       { "bc_srv_queue",         smp_fetch_conn_queues,  0,         NULL, SMP_T_SINT, SMP_USE_L4SRV }, /* "sq" */
+
        { "fc.timer.handshake",   smp_fetch_conn_timers,  0,         NULL, SMP_T_SINT, SMP_USE_L4CLI }, /* "Th" */
        { "fc.timer.total",       smp_fetch_conn_timers,  0,         NULL, SMP_T_SINT, SMP_USE_SSFIN }, /* "Tt" */