mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-26 08:11:21 +02:00
MINOR: log: Add logurilen tunable.
The default len of request uri in log messages is 1024. In some use cases, you need to keep the long trail of GET parameters. The only way to increase this len is to recompile with DEFINE=-DREQURI_LEN=2048. This commit introduces a tune.http.logurilen configuration directive, allowing to tune this at runtime.
This commit is contained in:
parent
a6cfa9098e
commit
23e9e93128
@ -598,6 +598,7 @@ The following keywords are supported in the "global" section :
|
|||||||
- tune.chksize
|
- tune.chksize
|
||||||
- tune.comp.maxlevel
|
- tune.comp.maxlevel
|
||||||
- tune.http.cookielen
|
- tune.http.cookielen
|
||||||
|
- tune.http.logurilen
|
||||||
- tune.http.maxhdr
|
- tune.http.maxhdr
|
||||||
- tune.idletimer
|
- tune.idletimer
|
||||||
- tune.lua.forced-yield
|
- tune.lua.forced-yield
|
||||||
@ -759,7 +760,8 @@ log <address> [len <length>] [format <format>] <facility> [max level [min level]
|
|||||||
truncate them before sending them. Accepted values are 80 to 65535
|
truncate them before sending them. Accepted values are 80 to 65535
|
||||||
inclusive. The default value of 1024 is generally fine for all
|
inclusive. The default value of 1024 is generally fine for all
|
||||||
standard usages. Some specific cases of long captures or
|
standard usages. Some specific cases of long captures or
|
||||||
JSON-formated logs may require larger values.
|
JSON-formated logs may require larger values. You may also need to
|
||||||
|
increase "tune.http.logurilen" if your request uris are truncated.
|
||||||
|
|
||||||
<format> is the log format used when generating syslog messages. It may be
|
<format> is the log format used when generating syslog messages. It may be
|
||||||
one of the following :
|
one of the following :
|
||||||
@ -1353,6 +1355,14 @@ tune.http.cookielen <number>
|
|||||||
When not specified, the limit is set to 63 characters. It is recommended not
|
When not specified, the limit is set to 63 characters. It is recommended not
|
||||||
to change this value.
|
to change this value.
|
||||||
|
|
||||||
|
tune.http.logurilen <number>
|
||||||
|
Sets the maximum length of request uri in logs. This prevent to truncate long
|
||||||
|
requests uris with valuable query strings in log lines. This is not related
|
||||||
|
to syslog limits. If you increase this limit, you may also increase the
|
||||||
|
'log ... len yyyy' parameter. Your syslog deamon may also need specific
|
||||||
|
configuration directives too.
|
||||||
|
The default value is 1024.
|
||||||
|
|
||||||
tune.http.maxhdr <number>
|
tune.http.maxhdr <number>
|
||||||
Sets the maximum number of headers in a request. When a request comes with a
|
Sets the maximum number of headers in a request. When a request comes with a
|
||||||
number of headers greater than this value (including the first line), it is
|
number of headers greater than this value (including the first line), it is
|
||||||
|
@ -273,7 +273,7 @@
|
|||||||
#define STREAM_MAX_COST (sizeof(struct stream) + \
|
#define STREAM_MAX_COST (sizeof(struct stream) + \
|
||||||
2 * sizeof(struct channel) + \
|
2 * sizeof(struct channel) + \
|
||||||
2 * sizeof(struct connection) + \
|
2 * sizeof(struct connection) + \
|
||||||
REQURI_LEN + \
|
global.tune.requri_len + \
|
||||||
2 * global.tune.cookie_len)
|
2 * global.tune.cookie_len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ struct global {
|
|||||||
int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
|
int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
|
||||||
int pipesize; /* pipe size in bytes, system defaults if zero */
|
int pipesize; /* pipe size in bytes, system defaults if zero */
|
||||||
int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
|
int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
|
||||||
|
int requri_len; /* max len of request URI, use REQURI_LEN if zero */
|
||||||
int cookie_len; /* max length of cookie captures */
|
int cookie_len; /* max length of cookie captures */
|
||||||
int pattern_cache; /* max number of entries in the pattern cache. */
|
int pattern_cache; /* max number of entries in the pattern cache. */
|
||||||
int sslcachesize; /* SSL cache size in session, defaults to 20000 */
|
int sslcachesize; /* SSL cache size in session, defaults to 20000 */
|
||||||
|
@ -897,6 +897,16 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
}
|
}
|
||||||
global.tune.cookie_len = atol(args[1]) + 1;
|
global.tune.cookie_len = atol(args[1]) + 1;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(args[0], "tune.http.logurilen")) {
|
||||||
|
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||||
|
goto out;
|
||||||
|
if (*(args[1]) == 0) {
|
||||||
|
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
global.tune.requri_len = atol(args[1]) + 1;
|
||||||
|
}
|
||||||
else if (!strcmp(args[0], "tune.http.maxhdr")) {
|
else if (!strcmp(args[0], "tune.http.maxhdr")) {
|
||||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||||
goto out;
|
goto out;
|
||||||
@ -7370,6 +7380,9 @@ int check_config_validity()
|
|||||||
if (!global.tune.cookie_len)
|
if (!global.tune.cookie_len)
|
||||||
global.tune.cookie_len = CAPTURE_LEN;
|
global.tune.cookie_len = CAPTURE_LEN;
|
||||||
|
|
||||||
|
if (!global.tune.requri_len)
|
||||||
|
global.tune.requri_len = REQURI_LEN;
|
||||||
|
|
||||||
pool2_capture = create_pool("capture", global.tune.cookie_len, MEM_F_SHARED);
|
pool2_capture = create_pool("capture", global.tune.cookie_len, MEM_F_SHARED);
|
||||||
|
|
||||||
/* Post initialisation of the users and groups lists. */
|
/* Post initialisation of the users and groups lists. */
|
||||||
|
@ -459,7 +459,7 @@ void init_proto_http()
|
|||||||
|
|
||||||
/* memory allocations */
|
/* memory allocations */
|
||||||
pool2_http_txn = create_pool("http_txn", sizeof(struct http_txn), MEM_F_SHARED);
|
pool2_http_txn = create_pool("http_txn", sizeof(struct http_txn), MEM_F_SHARED);
|
||||||
pool2_requri = create_pool("requri", REQURI_LEN, MEM_F_SHARED);
|
pool2_requri = create_pool("requri", global.tune.requri_len , MEM_F_SHARED);
|
||||||
pool2_uniqueid = create_pool("uniqueid", UNIQUEID_LEN, MEM_F_SHARED);
|
pool2_uniqueid = create_pool("uniqueid", UNIQUEID_LEN, MEM_F_SHARED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2959,8 +2959,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
|
|||||||
if ((txn->uri = pool_alloc2(pool2_requri)) != NULL) {
|
if ((txn->uri = pool_alloc2(pool2_requri)) != NULL) {
|
||||||
int urilen = msg->sl.rq.l;
|
int urilen = msg->sl.rq.l;
|
||||||
|
|
||||||
if (urilen >= REQURI_LEN)
|
if (urilen >= global.tune.requri_len )
|
||||||
urilen = REQURI_LEN - 1;
|
urilen = global.tune.requri_len - 1;
|
||||||
memcpy(txn->uri, req->buf->p, urilen);
|
memcpy(txn->uri, req->buf->p, urilen);
|
||||||
txn->uri[urilen] = 0;
|
txn->uri[urilen] = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user