Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Add prometheus-exporter to HAProxy (#659)
Browse files Browse the repository at this point in the history
* add prometheus-exporter to HAProxy build params.
https://www.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpoint/

* update tests. add endpoint to readme

Co-authored-by: Kamil Kayumov <[email protected]>
  • Loading branch information
rfvbkm and Kamil Kayumov authored Mar 24, 2020
1 parent d0b0ade commit fd1c710
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 56 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ RUN set -x \
USE_REGPARM=1 \
USE_STATIC_PCRE=1 \
USE_ZLIB=1 \
EXTRA_OBJS="contrib/prometheus-exporter/service-prometheus.o" \
all \
install-bin \
&& rm -rf /usr/src/haproxy \
Expand Down
114 changes: 58 additions & 56 deletions Longhelp.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Marathon-lb exposes a few endpoints on port 9090 (by default). They are:
| `:9090/_haproxy_getpids` | Returns the PIDs for all HAProxy instances within the current process namespace. This literally returns `$(pidof haproxy)`. Implemented in [`getpids.lua`](getpids.lua). This is also used by the [`zdd.py`](zdd.py) script to determine if connections have finished draining during a deploy. |
| `:9090/_mlb_signal/hup`* | Sends a `SIGHUP` signal to the marathon-lb process, causing it to fetch the running apps from Marathon and reload the HAProxy config as though an event was received from Marathon. |
| `:9090/_mlb_signal/usr1`* | Sends a `SIGUSR1` signal to the marathon-lb process, causing it to restart HAProxy with the existing config, without checking Marathon for changes. |
| `:9090/metrics` | Exposes HAProxy metrics in prometheus format. |

\* These endpoints won't function when marathon-lb is in `poll` mode as there is no marathon-lb process to be signaled in this mode (marathon-lb exits after each poll).

Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def load(self):
balance
mode http
stats enable
http-request use-service prometheus-exporter if { path /metrics }
monitor-uri /_haproxy_health_check
acl getpid path /_haproxy_getpids
http-request use-service lua.getpids if getpid
Expand Down
1 change: 1 addition & 0 deletions tests/test_marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def setUp(self):
balance
mode http
stats enable
http-request use-service prometheus-exporter if { path /metrics }
monitor-uri /_haproxy_health_check
acl getpid path /_haproxy_getpids
http-request use-service lua.getpids if getpid
Expand Down
1 change: 1 addition & 0 deletions tests/test_marathon_lb_haproxy_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def template_option(opt):
balance
mode http
stats enable
http-request use-service prometheus-exporter if { path /metrics }
monitor-uri /_haproxy_health_check
acl getpid path /_haproxy_getpids
http-request use-service lua.getpids if getpid
Expand Down

0 comments on commit fd1c710

Please sign in to comment.