]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: log: Add "sample" new keyword to "log" lines.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 24 Apr 2019 14:14:33 +0000 (16:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 30 Apr 2019 07:25:09 +0000 (09:25 +0200)
commitd95ea2897eb951c72fd169f36b6a79905f2ed999
treeb3f3ffc8e96f40c29d5f804563635e19f563bf3e
parentbf60f6b8033deddc86de5357d6099c7593fe44cc
MINOR: log: Add "sample" new keyword to "log" lines.

This patch implements the parsing of "sample" new optional keyword for "log" lines
to be able to sample and balance the load of log messages between serveral log
destinations declared by "log" lines. This keyword must be followed by a list of
comma seperated ranges of indexes numbered from 1 to define the samples to be used
to balance the load of logs to send. This "sample" keyword must be used on "log" lines
obviously before the remaining optional ones without keyword. The list of ranges
must be followed by a colon character to separate it from the log sampling size.

With such following configuration declarations:

   log stderr local0
   log 127.0.0.1:10001 sample 2-3,8-11:11 local0
   log 127.0.0.2:10002 sample 5:5 local0

in addition to being sent to stderr, about the second "log" line, every 11 logs
the logs #2 up to #3 would be sent to 127.0.0.1:10001, then #8 up tp #11 four
logs would be sent to the same log server and so on periodically. Logs would be
sent to 127.0.0.2:100002 every 5 logs.

It is also possible to define the size of the sample with a value different of
the maximum of the high limits of the ranges, for instance as follows:

   log 127.0.0.1:10001 sample 2-3,8-11:15 local0

as before the two logs #2 and #3 would be sent to 127.0.0.1:10001, then #8
up tp #11 logs, but in this case here, this would be done periodically every 15
messages.

Also note that the ranges must not overlap each others. This is to ease the
way the logs are periodically sent.
include/types/log.h
src/log.c