]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sample: extend the "when" converter to support an ACL
authorWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 14:27:28 +0000 (15:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 18 Nov 2024 15:11:55 +0000 (16:11 +0100)
commit45f9e95f2276dd712b07a241e22ef15d5e65de95
tree1976d1f474b72fee748b8647b2ce76b07ffc2363
parent00fcda1ff28c7826d230a4dd3b235b5be19cac07
MINOR: sample: extend the "when" converter to support an ACL

Sometimes conditions to decide of an anomaly are not as easy to define
as just an error or a success. One example use case would be to monitor
the transfer time and fix a threshold.

An idea suggested by Tristan would be to make permit the "when"
converter to refer to a more variable or dynamic condition.

Here we make this possible by making "when" rely on a named ACL. The
ACL then needs to be specified in either the proxy or the defaults
section. Since it is evaluated inline, it may even refer to information
available at the end (at log time) such as the data transfer time. If
the ACL evalutates to true, the converter passes the data.

Example: log "dbg={-}" when fine, or "dbg={... debug info ...}" on slow
transfers:

  acl slow_xfer res.timer.data ge 10000   # more than 10s is slow
  log-format "$HAPROXY_HTTP_LOG_FMT                                \
              fsdbg={%[fs.debug_str,when(acl,slow_xfer)]}          \
              bsdbg={%[bs.debug_str,when(acl,slow_xfer)]}"
doc/configuration.txt
src/sample.c