r/haproxy: Enable Prometheus metrics
HAProxy can export stats in Prometheus format, but this requires special configuration of a dedicated front-end. To support this, the _haproxy_ Ansible role now has a pair of variables, `haproxy_enable_stats` and `haproxy_stats_port`, which control whether or not the stats front-end is enabled, and if so, what port it listens on. Note that on Fedora with the default SELinux policy, the port must be labelled either `http_port_t` or `http_cache_port_t`.
This commit is contained in:
10
roles/haproxy/templates/stats.cfg.j2
Normal file
10
roles/haproxy/templates/stats.cfg.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
{% if haproxy_enable_stats %}
|
||||
frontend stats
|
||||
bind *:{{ haproxy_stats_port }}
|
||||
http-request use-service prometheus-exporter if { path /metrics }
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats refresh 10s
|
||||
{% else %}
|
||||
# HAProxy stats frontend is disabled.
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user