HAProxy Enterprise Documentation 2.4r1

Send Metrics

The Send Metrics module streams HAProxy Enterprise metrics data to an external program. Which fields to include in the data is configurable.

Enable the Send Metrics module

  1. Install the module using your package manager:

    $ # On Debian/Ubuntu
    $ sudo apt-get install hapee-2.4r1-lb-send-metrics
    $ # On CentOS/RedHat/Oracle/Photon OS
    $ sudo yum install hapee-2.4r1-lb-send-metrics
    $ # On SUSE
    $ sudo zypper install hapee-2.4r1-lb-send-metrics
    $ # On FreeBSD
    $ sudo pkg install hapee-2.4r1-lb-send-metrics
  2. Update the global section of your configuration file to send the data. Below is an example that:

    • sends data to the URL http://192.168.0.10:8000/metrics/ using an HTTP POST request;

    • sends data at a one minute interval;

    • format the data as JSON;

    • sends the server's hostname, the date, and the current number of active connections;

    • attaches an HTTP header named X-APIKey to the request.

    global
       module-path /opt/hapee-2.4/modules
       module-load hapee-lb-send-metrics.so
       send-metrics-url POST http://192.168.0.10:8000/metrics/  xdelay 1m 5s 1s 1s  timeout 100ms  retries 3  log
       send-metrics-content-type application/json
       send-metrics-data '{ "Hostname": "%H", "Date": "%T", "connections": "%ac" }'
       send-metrics-header 'X-APIKey: abcd1234'

    See the section below for an explanation of each directive and its parameters.

Global parameters

The Send Metrics module accepts the following directives 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): Tells HAProxy Enterprise to update data metrics over HTTP to a specified URL.

    where:

    post <url> (required)

    Specifies the URL for data metrics update.

    delay <u>

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

    xdelay <u s b r>

    Delay settings are defined as follows:

    • <u> specifies the period between each attempt to send new data metrics. If the module cannot send the metrics data after three attempts, it cancels the update until the next time interval defined by <u>. Default: 60m

    • <s> specifies the initial (first) delay to send the data. Default: 5s

    • <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. Default: 10s

    • If the data fails to send, <r> determines the delay for the next attempt. Default: 5s

    timeout <t>

    Specifies the HTTP connection timeout for attempts to send new data metrics. The value is in milliseconds by default, but you can set it to any other unit if you add it as a suffix to the number. Default: 5s

    retries <n>

    Specifies number of retries to send new data metrics. If unspecified, HAProxy Enterprise uses the global retries value. Default: 3s

    log

    Specifies whether to log operation errors.

    dontlog-normal

    Deactivates logging for successful updates.

    param*

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

  • send-metrics-data <data> (required): Data to send to the selected HTTP server. You can set individual log variables within the data (prefixed with %).

  • send-metrics-content-type <content-type>: Allows the module to set the "Content-Type" header when sending data, including and limited to the content types listed below. If unspecified, the module uses the "application/octet-stream" Content-Type.

    Supported content types are:

    • application/json

    • application/octet-stream

    • application/x-www-form-urlencoded

    • text/plain

  • send-metrics-header <header> [header]...: Allows the module to set additional HTTP headers within the HTTP POST request.

  • send-metrics-debug <level>: Sets the debug level. Use this only when the module runs in debug mode; in normal use, it has no significance. Default: level 7.

HAProxy Runtime API

The following Runtime API commands are available:

lb-send-metrics show-data

Serves to check the operation of the module by printing the content similar to the one that the module sent to the selected HTTP server.

lb-send-metrics status

Displays the module's status.

lb-send-metrics update [delay]

Runs the update at a time specified with the delay setting. If unspecified (or the delay is 0), the update executes immediately. The delay cannot exceed the time until the next regular update.

lb-send-metrics debug [level]

Sets the debug level. Sets the debug level. You can use this only when the module runs in debug mode; in normal use it has no significance. Default: level 7.


Next up

SNMP