This module enables streaming HAProxy metrics to an external program. It adds the ability to send user-formatted data to configured URLs periodically. A good use-case is sending metrics to third-party APIs. Standard HAProxy log-format rules and variables are available.

Install the Send Metrics module

  1. Install the Send Metrics module: apt install hapee-1.5r2-lb-send-metrics (or yum install depending on your platform of choice).

  2. In the global section of your configuration, add the following lines:

    send-metrics-debug 127
    send-metrics-url POST http://localhost:8000/v1/feed/__SourceUUID__  xdelay 1m 5s 1s 1s  timeout 100ms  retries 3  log
    send-metrics-header 'X-NSONE-Key: __APIKey__' 'X-Send-Metrics: 42'
    send-metrics-content-type application/json
    send-metrics-data '{ "lga01": { "Hostname": "%H", "Date": "%T", "connections": "%ac" } }'

Global Parameters

The following directives are supported in the global section:



send-metrics-url post <url> [delay <u> | xdelay <u s b r>] [timeout <t>] [retries <n>] [log] [dontlog-normal] [param*] (required)

This option enables updating the data metrics over HTTP to a specified URL.

post <url> (required)

This option specifies the data metrics update URL.

delay <u>

<u> specifies the period between each attempt to send a new data metrics. The delay keyword is a simplified version of the xdelay keyword.

xdelay <u s b r>

<u> specifies the period between each attempt to send a new data metrics. <s> specifies the initial (first) data send delay. <b> parameter is not used in this module and its value is not important. It is present only because of the compatibility of xdelay parameters with other lb-update-like modules. If the data send fails, <r> determines the delay for the next attempt.

Default values for <u>, <s>, <b> and <r> are 60m, 5s, 10s and 5s, respectively. If after three attempts, the metrics data can not be sent, the update is cancelled until the next time interval defined by <u>.

timeout <t>

Specifies the HTTP connect timeout for attempts to send new data metrics. The value is specified in milliseconds by default, but can be in any other unit if the number is suffixed by the unit. Default is 5 seconds.

retries <n>

Specifies number of retries to send new data metrics. If unspecified, the global :code`retries` value is used (defaults to 3).


Specifies whether to log operation errors.


Deactivates logging of successful updates.


A list of other server line parameters for HAProxy. This is useful for configuring special SSL features. This includes :code`ca-file`, verify [none|optional|required], etc.

send-metrics-data <data> (required)

Data that is send to the selected HTTP server. It is possible to set individual log variables within the data (which begin with the prefix %).

send-metrics-content-type <content-type>

Allows setting the Content-Type header when sending data. Only those types listed in the table below are supported. If not specified, the module uses the application/octet-stream Content-Type.

Supported content types:

  • application/json

  • application/octet-stream

  • application/x-www-form-urlencoded

  • text/plain

send-metrics-debug <level>

Set the debug level. The default debug level is 7. This keyword can only be used when the module is compiled in debug mode and in normal use it has no significance.

send-metrics-header <header> [header]...

Allows setting of additional HTTP headers within the HTTP POST request.

HAProxy Runtime API

The following Runtime API commands are available:

lb-send-metrics debug [level]

Set the debug level. The default debug level is 7. This command can only be used when the module is compiled in debug mode, and in normal use it has no significance.

lb-send-metrics show-data

Serves for checking the operation of the module. It prints the content similar to the one that is sent to the selected HTTP server.

lb-send-metrics status

The module's status is displayed.

lb-send-metrics update [delay]

Run the update at a time specified with the delay argument. If the delay is not specified (or the delay is 0), the update will be executed immediately. The delay cannot be greater than the time until the next regular update.