Conditonnal log

Bonjour,

I would like write log only for certain events :

frontend http
bind *:80
bind *:443 ssl crt .....

stick-table type ip size 1m expire 10s store http_req_rate(10s)
tcp-request inspect-delay 10s
tcp-request content track-sc1 src

acl abusive_ip sc1_http_req_rate gt  200
LOG if abusive_ip

what is the directive do i need to write instead of LOG, to log the abusive request.

thanks

Take a look at the http-request set-log-level

log     /var/lib/haproxy/dev/log local0 notice
stick-table type ip size 1m expire 10s store http_req_rate(10s)
tcp-request inspect-delay 10s
tcp-request content track-sc1 src

acl abusive_ip sc1_http_req_rate gt 200

i try adding :
http-request set-log-level debug if abusive_ip

or


http-request capture req.hdr(Host) len 10 if abusive_ip

And it write nothing about the request in the log file.
:thinking:

I suggest you try first to set it to debug logging entirey (in the log statement, without set-log-level).

Once you confirmed that you are generally able to see the debug messages, then you can proceed with conditional debug logging.

I got it !


global
        log     /var/lib/haproxy/dev/log local0 notice
...
defaults
        log global
        mode http
...

frontend http
...
        http-request set-log-level notice if abusive_ip

set-log-level need to send the http-request to the current log-level , and not send it to the debug level.

:triumph: :wink: