OPNsense Forum

English Forums => General Discussion => Topic started by: svs on May 18, 2021, 06:28:38 pm

Title: HAProxy plugin with prometheus exporter enabled
Post by: svs on May 18, 2021, 06:28:38 pm
I'm somewhat new to OPNsense. I am trying to use prometheus to collect metrics from HAProxy. Unfortunately, the default haproxy plugin does not have the built-in prometheus exporter enabled, as described in https://github.com/haproxy/haproxy/tree/master/addons/promex .

Is there a version of the haproxy plugin with promex enabled that I can use?
Thanks!
Title: Re: HAProxy plugin with prometheus exporter enabled
Post by: svs on May 25, 2021, 06:38:33 pm
Opened a ticket to have this included:
https://github.com/opnsense/tools/issues/230
Title: Re: HAProxy plugin with prometheus exporter enabled
Post by: henningkessler on September 02, 2021, 12:25:29 pm
Hi there,

your ticket has been closed. Is the promex now build into HAProxy? And if so how did you configure it as there seams to be no GUI for it?

Henning
Title: Re: HAProxy plugin with prometheus exporter enabled
Post by: svs on September 03, 2021, 09:55:24 pm
Updated to v21.7.1 and confirm the HAProxy built-in Prometheus exporter (promex) is working well now.

You can find a description how to set this up here:
https://www.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpoint/#configuring-prometheus
https://forum.netgate.com/topic/153766/haproxy-2-0-prometheus-monitoring-how-to

I added a Public Service through the GUI, which resulted in this config:
Code: [Select]
# Frontend: Prometheus (Prometheus metrics exporter)
frontend Prometheus
    bind *:9105 name *:9105
    mode http
    option http-keep-alive
    # tuning options
    maxconn 10
    timeout client 30s

    # logging options
    option dontlog-normal
    # WARNING: pass through options below this line
    option http-use-htx
    http-request use-service  prometheus-exporter if { path /metrics }

Hope it helps!
Title: Re: HAProxy plugin with prometheus exporter enabled
Post by: henningkessler on September 04, 2021, 04:29:59 pm
Yes, helps a lot. Thank you!!
Title: Re: HAProxy plugin with prometheus exporter enabled
Post by: fraenki on October 22, 2022, 01:23:18 am
os-haproxy version 3.12 will include GUI options to enable the Prometheus exporter:
https://github.com/opnsense/plugins/issues/2764#issuecomment-1287528782