diff --git a/jobs/haproxy/templates/haproxy.config.erb b/jobs/haproxy/templates/haproxy.config.erb index 07c14cf5..b1644a20 100644 --- a/jobs/haproxy/templates/haproxy.config.erb +++ b/jobs/haproxy/templates/haproxy.config.erb @@ -362,7 +362,7 @@ listen stats acl private src <%= p("ha_proxy.trusted_stats_cidrs") %> http-request deny unless private mode http - <%- if_p("ha_proxy.stats_promex_enable") do -%> + <%- if p("ha_proxy.stats_promex_enable") -%> http-request use-service prometheus-exporter if { path <%= p("ha_proxy.stats_promex_path") %> } <%- end -%> stats enable diff --git a/spec/haproxy/templates/haproxy_config/stats_listener_spec.rb b/spec/haproxy/templates/haproxy_config/stats_listener_spec.rb index 18caa5fa..6c0a3630 100644 --- a/spec/haproxy/templates/haproxy_config/stats_listener_spec.rb +++ b/spec/haproxy/templates/haproxy_config/stats_listener_spec.rb @@ -44,6 +44,12 @@ end end + context 'when ha_proxy.stats_promex_enable is false (default)' do + it 'does not include a prometheus exporter endpoint' do + expect(stats_listener).not_to include(a_string_including('prometheus-exporter')) + end + end + context 'when ha_proxy.trusted_stats_cidrs is set' do let(:properties) do default_properties.merge({ 'trusted_stats_cidrs' => '1.2.3.4/32' })