Enterprise modules

Send metrics

Available since

  • HAProxy Enterprise 1.8r1

The Send Metrics module streams HAProxy Enterprise metrics to an external program. You can configure which fields to include in the data.

Install the Send Metrics module Jump to heading

  1. Install the module using your package manager:

    bash
    sudo apt-get install hapee-2.8r1-lb-send-metrics
    bash
    sudo apt-get install hapee-2.8r1-lb-send-metrics
    bash
    sudo yum install hapee-2.8r1-lb-send-metrics
    bash
    sudo yum install hapee-2.8r1-lb-send-metrics
    bash
    sudo zypper install hapee-2.8r1-lb-send-metrics
    bash
    sudo zypper install hapee-2.8r1-lb-send-metrics
    bash
    sudo pkg install hapee-2.8r1-lb-send-metrics
    bash
    sudo pkg install hapee-2.8r1-lb-send-metrics
  2. Update the global section of your configuration to send the data:

    haproxy
    global
    module-path /opt/hapee-2.8/modules
    module-load hapee-lb-send-metrics.so
    send-metrics-url POST http://192.168.0.1: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'
    haproxy
    global
    module-path /opt/hapee-2.8/modules
    module-load hapee-lb-send-metrics.so
    send-metrics-url POST http://192.168.0.1: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'

    In this example, we:

    • sends data at a 1 minute interval to the URL http://192.168.0.1:8000/metrics/ using an HTTP POST request.
    • 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.

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

Global directives Jump to heading

The Send Metrics module enables the following directives in the global section.

send-metrics-url Jump to heading

The send-metrics-url directive is required. It tells the load balancer to send metrics data over HTTP to a specified URL.

Syntax:

send-metrics-url POST <url> [delay <u> | xdelay <u s b r>] [timeout <t>] [retries <n>] [log] [dontlog-normal]

where:

Argument Description
post <url> Required. Specifies the URL to send metrics data to.
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> <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>. It defaults to 60m. <s> specifies the initial (first) delay to send the data. It defaults to 5s. <b> is not used in this module and its value is not important. It defaults to 10s. If the data fails to send, <r> determines the delay for the next attempt. It defaults to 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 arguments. This is useful for configuring special TLS features.

send-metrics-data Jump to heading

The send-metrics-data directive is required. It sets the data to send to the selected HTTP server. You can set individual log variables within the data, prefixed with %.

send-metrics-content-type Jump to heading

  • The send-metrics-content-type directive 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 Jump to heading

The send-metrics-header directive allows the module to set additional HTTP headers within the HTTP POST request.

send-metrics-debug Jump to heading

The send-metrics-debug directive sets the debug level. Use this only when the module runs in debug mode; in normal use, it has no significance. Default: level 7.

Runtime API Jump to heading

The following Runtime API commands are available:

lb-send-metrics show-data Jump to heading

The lb-send-metrics show-data command serves to check the operation of the module by printing the content the module sent to the selected HTTP server.

lb-send-metrics status Jump to heading

The lb-send-metrics status command displays the module’s status.

lb-send-metrics update Jump to heading

The lb-send-metrics update [delay] command 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 Jump to heading

The lb-send-metrics debug [level] command 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.

If this page was useful, please, Leave the feedback.