A router is one way to get traffic into the cluster. The haproxy Template Router plug-in is one of the available router plugins.
The template router has two components:
a wrapper that watches endpoints and routes and causes a haproxy reload based on changes.
a controller that builds the haproxy configuration file based on routes and endpoints.
The haproxy router uses version 1.5.18. |
The controller and haproxy are housed inside a pod, which is managed by a deployment configuration. The process of setting up the router is automated
by the oc adm router
command.
The controller watches the routes and endpoints for changes, as well as haproxy’s health. When a change is detected, it builds a new haproxy-config file and restarts haproxy. The haproxy-config file is constructed based on the router’s template file and information from OKD.
The haproxy template file can be customized as needed to support features that are not currently supported by OKD. The haproxy manual describes all of the features supported by haproxy.
The following diagram illustrates how data flows from the master through the plug-in and finally into an haproxy configuration:
The haproxy router exposes or publishes metrics in Prometheus format for consumption by external metrics collection and aggregation systems (e.g. Prometheus, statsd). The router can be configured to provide haproxy CSV format metrics, or provide no router metrics at all.
The metrics are collected from both the router controller and from haproxy every 5 seconds. The router metrics counters start at zero when the router is deployed and increase over time. The haproxy metrics counters are reset to zero every time haproxy is reloaded. The router collects haproxy statistics for each frontend, backend and server. To reduce resource usage when there are more than 500 servers, the backends are reported instead of the servers since a backend can have multiple servers.
The statistics are a subset of the available haproxy Statistics.
The following haproxy metrics are collected on a preiodic basis and converted to Prometheus format. For every frontend the "F" counters are collected. When the total number of servers is less than the Server Threshold (default 500), the "b" counters are collected for each backend and the "S" server counters are collected for each server. Otherwise, the "B" counters are collected for each backend and no server counters are collected.
In the following table:
Column 1 - Index from haproxy CSV statistics
Column 2
F |
Frontend metrics |
b |
Backend metrics when not showing Server metrics due to the Server Threshold, |
B |
Backend metrics when showing Server metrics |
S |
Server metrics. |
Column 3 - The counter
Column 4 - Counter description
Index |
Usage |
Counter |
Description |
2 |
bBS |
current_queue |
Current number of queued requests not assigned to any server. |
4 |
FbS |
current_sessions |
Current number of active sessions. |
5 |
FbS |
max_sessions |
Maximum observed number of active sessions. |
7 |
FbBS |
connections_total |
Total number of connections. |
8 |
FbS |
bytes_in_total |
Current total of incoming bytes. |
9 |
FbS |
bytes_out_total |
Current total of outgoing bytes. |
13 |
bS |
connection_errors_total |
Total of connection errors. |
14 |
bS |
response_errors_total |
Total of response errors. |
17 |
bBS |
up |
Current health status of the backend (1 = UP, 0 = DOWN). |
21 |
S |
check_failures_total |
Total number of failed health checks. |
24 |
S |
downtime_seconds_total |
Total downtime in seconds.", nil), |
33 |
FbS |
current_session_rate |
Current number of sessions per second over last elapsed second. |
35 |
FbS |
max_session_rate |
Maximum observed number of sessions per second. |
40 |
FbS |
http_responses_total |
Total of HTTP responses, code 2xx |
43 |
FbS |
http_responses_total |
Total of HTTP responses, code 5xx |
60 |
FbS |
http_average_response_latency_milliseconds |
of the last 1024 requests in milliseconds. |
The router controller scrapes the following items. These are only available with Prometheus format metrics.
Name |
Description |
template_router_reload_seconds |
Measures the time spent reloading the router in seconds. |
template_router_write_config_seconds |
Measures the time spent writing out the router configuration to disk in seconds. |
haproxy_exporter_up |
Was the last scrape of haproxy successful. |
haproxy_exporter_csv_parse_failures |
Number of errors while parsing CSV. |
haproxy_exporter_scrape_interval |
The time in seconds before another scrape is allowed, proportional to size of data. |
haproxy_exporter_server_threshold |
Number of servers tracked and the current threshold value. |
haproxy_exporter_total_scrapes |
Current total haproxy scrapes. |
http_request_duration_microseconds |
The HTTP request latencies in microseconds. |
http_request_size_bytes |
The HTTP request sizes in bytes. |
http_response_size_bytes |
The HTTP response sizes in bytes. |
openshift_build_info |
A metric with a constant '1' value labeled by major, minor, git commit & git version from which OpenShift was built. |
ssh_tunnel_open_count |
Counter of SSH tunnel total open attempts |
ssh_tunnel_open_fail_count |
Counter of SSH tunnel failed open attempts |