MINOR: samples: implement bytes_in and bytes_out samples

%[bytes_in] and %[bytes_out] are equivalent to %U and %B tags in
log-format.
This commit is contained in:
William Lallemand 2023-08-23 16:45:05 +02:00
parent 5abbae2d3d
commit c7424a1bac
2 changed files with 35 additions and 0 deletions

View File

@ -22063,6 +22063,13 @@ baseq : string
instead of "base" allows one to properly identify the target resource, for
statistics or caching use cases. See also "path", "pathq" and "base".
bytes_in : integer
This returns the number of bytes uploaded from the client to the server.
bytes_out integer
This is the number of bytes transmitted from the server to the client.
capture.req.hdr(<idx>) : string
This extracts the content of the header captured by the "capture request
header", idx is the position of the capture keyword in the configuration.
@ -23745,6 +23752,7 @@ Please refer to the table below for currently defined variables :
| Others |
+---+------+------------------------------------------------------+---------+
| | %B | bytes_read (from server to client) | numeric |
| | | %[bytes_out] | |
+---+------+------------------------------------------------------+---------+
| H | %CC | captured_request_cookie | string |
+---+------+------------------------------------------------------+---------+
@ -23769,6 +23777,7 @@ Please refer to the table below for currently defined variables :
| | %ST | status_code | numeric |
+---+------+------------------------------------------------------+---------+
| | %U | bytes_uploaded (from client to server) | numeric |
| | | %[bytes_in] | |
+---+------+------------------------------------------------------+---------+
| | %ac | actconn | |
| | | %[act_conn] | numeric |

View File

@ -4905,9 +4905,35 @@ error:
return 0;
}
/* bytes_{in,out} */
static int smp_fetch_bytes(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 (!logs)
return 0;
if (kw[6] == 'i') { /* bytes_in */
smp->data.u.sint = logs->bytes_in;
} else { /* bytes_out */
smp->data.u.sint = logs->bytes_out;
}
return 1;
}
static struct sample_fetch_kw_list smp_logs_kws = {ILH, {
{ "bytes_in", smp_fetch_bytes, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
{ "bytes_out", smp_fetch_bytes, 0, NULL, SMP_T_SINT, SMP_USE_INTRN },
{ "txn.timer.total", smp_fetch_txn_timers, 0, NULL, SMP_T_SINT, SMP_USE_TXFIN }, /* "Ta" */
{ "txn.timer.user", smp_fetch_txn_timers, 0, NULL, SMP_T_SINT, SMP_USE_TXFIN }, /* "Tu" */