I am currently adding rate limiting to http and mqtt services in haproxy. These are working, but I also want to show the blocked requests in the logs. On the http frontend I return a 429 and on the mqtt I close the connection on blocked requests.
But when I enable logs, ALL logs are shown.
global
log 127.0.0. local notice
defaults
log global
option httplog
#sticky tables
backend st_http
stick-table type ipv6 size 100k expire 10s store http_req_rate(10s)
backend st_mqtt
stick-table type ipv6 size 100k expire 10s store conn_rate(10s)
frontend public-https
log stdout format short daemon warning
#rate limiting
http-request track-sc0 src table st_api_requests
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 100 }
# ...
listen mqtt:
mode tcp
option tcplog
log stdout format short daemon warning
# rate limiting
tcp-request connection track-sc0 src table st_mqtt_connections
tcp-request connection reject if { sc_conn_rate(0) gt 2 }
# ...
How can I only show faulty requests, i.e. all 4xx and 5xx requests on http and all blocked connections on mqtt?
// My current tests only show all log output of a service or none depending on the loglevel. How can I make this more selective?
//edit2 added acls for rate limiting