Skip to content

Commit

Permalink
Add unix socket to HAProxy stats configuration info (elastic#23727)
Browse files Browse the repository at this point in the history
* Add unix socket to HAProxy stats configuration info

* Run make update
  • Loading branch information
dedemorton authored Feb 3, 2021
1 parent eb16ea9 commit 86d87c8
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 26 deletions.
53 changes: 40 additions & 13 deletions metricbeat/docs/modules/haproxy.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,50 @@ This file is generated! See scripts/mage/docs_collector.go
== HAProxy module

This module collects stats from http://www.haproxy.org/[HAProxy]. It supports
collection from using TCP sockets or HTTP with or without basic authentication.
collection from TCP sockets, UNIX sockets, or HTTP with or without basic
authentication.

To configure HAProxy to collect stats, you must enable the stats module, it can
be done by enabling a TCP socket, or by adding an HTTP stats frontend.
Metricbeat can collect two metricsets from HAProxy: `info` and `stat`. `info`
is not available when using the stats page.

Metricbeat can collect two metric sets from HAProxy, `info` and `stats`. `info`
is not available when using HTTP stats frontend.
[float]
=== Configure HAProxy to collect stats

For example, to enable stats reporting via any local IP on port 14567, place
this statement under the `global` or `default` section of the haproxy config:
Before you can use Metricbeat to collect stats, you must enable the stats module
in HAProxy. You can do this a couple of ways: configure HAProxy to
report stats via a TCP or UNIX socket, or enable the stats page.

[source,haproxy]
[float]
==== TCP socket

To enable stats reporting via any local IP on port 14567, add the following line
to the `global` or `default` section of the HAProxy config:

[source,shell]
----
stats socket 127.0.0.1:14567
----

NOTE: You should use an internal private IP, or secure this with a firewall
rule, so that only designated hosts can access this data.

To configure the HTTP stats frontend, a frontend with stats enabled has to
be added. For example, to open this frontend to any IP on port 14567 with
required authentication add this to the haproxy config:
[float]
==== UNIX socket

To enable stats reporting via a UNIX socket, add the following line to the
`global` or `default` section of the HAProxy config:

[source,shell]
----
stats socket /path/to/haproxy.sock mode 660 level admin
----

[float]
==== Stats page

To enable the HAProxy stats page, add the following lines to the HAProxy config,
then restart HAProxy. The stats page in this example will be available to any IP
on port 14567 after authentication.

[source,haproxy]
----
Expand All @@ -38,12 +60,11 @@ required authentication add this to the haproxy config:
stats auth admin:admin
----

The default metricsets are `info`and `stat`.

[float]
=== Compatibility

The HAProxy metricsets are tested with HAProxy versions from 1.6, 1.7 to 1.8.
The HAProxy metricsets are tested with HAProxy versions from 1.6 to 1.8.


[float]
Expand All @@ -58,7 +79,13 @@ metricbeat.modules:
- module: haproxy
metricsets: ["info", "stat"]
period: 10s
# TCP socket, UNIX socket, or HTTP address where HAProxy stats are reported
# TCP socket
hosts: ["tcp://127.0.0.1:14567"]
# UNIX socket
#hosts: ["unix:///path/to/haproxy.sock"]
# Stats page
#hosts: ["http://127.0.0.1:14567"]
username : "admin"
password : "admin"
enabled: true
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,13 @@ metricbeat.modules:
- module: haproxy
metricsets: ["info", "stat"]
period: 10s
# TCP socket, UNIX socket, or HTTP address where HAProxy stats are reported
# TCP socket
hosts: ["tcp://127.0.0.1:14567"]
# UNIX socket
#hosts: ["unix:///path/to/haproxy.sock"]
# Stats page
#hosts: ["http://127.0.0.1:14567"]
username : "admin"
password : "admin"
enabled: true
Expand Down
6 changes: 6 additions & 0 deletions metricbeat/module/haproxy/_meta/config.reference.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
- module: haproxy
metricsets: ["info", "stat"]
period: 10s
# TCP socket, UNIX socket, or HTTP address where HAProxy stats are reported
# TCP socket
hosts: ["tcp://127.0.0.1:14567"]
# UNIX socket
#hosts: ["unix:///path/to/haproxy.sock"]
# Stats page
#hosts: ["http://127.0.0.1:14567"]
username : "admin"
password : "admin"
enabled: true
47 changes: 34 additions & 13 deletions metricbeat/module/haproxy/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
This module collects stats from http://www.haproxy.org/[HAProxy]. It supports
collection from using TCP sockets or HTTP with or without basic authentication.
collection from TCP sockets, UNIX sockets, or HTTP with or without basic
authentication.

To configure HAProxy to collect stats, you must enable the stats module, it can
be done by enabling a TCP socket, or by adding an HTTP stats frontend.
Metricbeat can collect two metricsets from HAProxy: `info` and `stat`. `info`
is not available when using the stats page.

Metricbeat can collect two metric sets from HAProxy, `info` and `stats`. `info`
is not available when using HTTP stats frontend.
[float]
=== Configure HAProxy to collect stats

For example, to enable stats reporting via any local IP on port 14567, place
this statement under the `global` or `default` section of the haproxy config:
Before you can use Metricbeat to collect stats, you must enable the stats module
in HAProxy. You can do this a couple of ways: configure HAProxy to
report stats via a TCP or UNIX socket, or enable the stats page.

[source,haproxy]
[float]
==== TCP socket

To enable stats reporting via any local IP on port 14567, add the following line
to the `global` or `default` section of the HAProxy config:

[source,shell]
----
stats socket 127.0.0.1:14567
----

NOTE: You should use an internal private IP, or secure this with a firewall
rule, so that only designated hosts can access this data.

To configure the HTTP stats frontend, a frontend with stats enabled has to
be added. For example, to open this frontend to any IP on port 14567 with
required authentication add this to the haproxy config:
[float]
==== UNIX socket

To enable stats reporting via a UNIX socket, add the following line to the
`global` or `default` section of the HAProxy config:

[source,shell]
----
stats socket /path/to/haproxy.sock mode 660 level admin
----

[float]
==== Stats page

To enable the HAProxy stats page, add the following lines to the HAProxy config,
then restart HAProxy. The stats page in this example will be available to any IP
on port 14567 after authentication.

[source,haproxy]
----
Expand All @@ -31,9 +53,8 @@ required authentication add this to the haproxy config:
stats auth admin:admin
----

The default metricsets are `info`and `stat`.

[float]
=== Compatibility

The HAProxy metricsets are tested with HAProxy versions from 1.6, 1.7 to 1.8.
The HAProxy metricsets are tested with HAProxy versions from 1.6 to 1.8.
6 changes: 6 additions & 0 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,13 @@ metricbeat.modules:
- module: haproxy
metricsets: ["info", "stat"]
period: 10s
# TCP socket, UNIX socket, or HTTP address where HAProxy stats are reported
# TCP socket
hosts: ["tcp://127.0.0.1:14567"]
# UNIX socket
#hosts: ["unix:///path/to/haproxy.sock"]
# Stats page
#hosts: ["http://127.0.0.1:14567"]
username : "admin"
password : "admin"
enabled: true
Expand Down

0 comments on commit 86d87c8

Please sign in to comment.