Introduction
HAProxy is a high-performance, open-source load balancer and reverse proxy for TCP and HTTP applications. Monitoring HAProxy is essential for tracking key performance metrics such as request rates, response times, error rates, active sessions, and backend health.
To monitor HAProxy efficiently, we can use the OpenTelemetry HAProxy Receiver, which collects key HAProxy performance metrics and makes them available for analysis.
Steps to Configure
Step 1: Check for Existing ConfigMap
Run the following command to see if the opsramp-workload-metric-user-config ConfigMap already exists:
kubectl get configmap opsramp-workload-metric-user-config -n <agent-installed-namespace>Step 2: Create a New ConfigMap (if not available)
If this is your first setup, create a workload-master ConfigMap. Use the following template and update it as per your workload requirements:
apiVersion: v1
kind: ConfigMap
metadata:
name: haproxy-config
namespace: default
data:
haproxy.cfg: |
global
log stdout format raw local0
stats socket /var/run/haproxy.sock mode 660 level admin
maxconn 4000
defaults
mode http
log global
option httplog
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http_front
bind *:8080 # Changed from 80 to 8080
default_backend http_back
backend http_back
balance roundrobin
server server1 127.0.0.1:8080 check
listen stats
bind *:8081 # Changed from 8404 to 8081
stats enable
stats uri /stats
stats refresh 10sNote
Ensure there are no extra spaces at the end of any line in the manifest. Extra spaces can cause rendering issues.Step 3: Apply the ConfigMap
kubectl apply -f <path-to-your-manifest-file>Step 4: Verify in OpsRamp Portal
After a few minutes, check metrics in the OpsRamp Portal > Dashboards > Dashboard.
Step 5: Set Up Alerts and Availability Rules
Once metrics are visible, you can configure alerts and availability rules in the OpsRamp portal. Edit the relevant ConfigMaps to adjust workload or application-specific monitoring.
Supported Metrics
Supported metrics for this workload as provided by the Kubernetes 2.0 Agent.
| Metric | Description |
|---|---|
| haproxy_bytes_input | Total number of bytes received by HAProxy |
| haproxy_bytes_output | Total number of bytes sent by HAProxy |
| haproxy_connections_errors | Number of connection errors in HAProxy |
| haproxy_connections_rate | Rate of new connections in HAProxy |
| haproxy_connections_retries | Number of connection retries in HAProxy |
| haproxy_requests_denied | Number of denied requests in HAProxy |
| haproxy_requests_errors | Number of requests that resulted in errors in HAProxy |
| haproxy_requests_queued | Number of requests queued in HAProxy |
| haproxy_requests_rate | Rate of requests received by HAProxy |
| haproxy_requests_redispatched | Number of requests redispatched by HAProxy |
| haproxy_requests_total | Total number of requests received by HAProxy |
| haproxy_responses_denied | Number of denied responses in HAProxy |
| haproxy_responses_errors | Number of responses that resulted in errors in HAProxy |
| haproxy_server_selected_total | Total number of times a server was selected in HAProxy |
| haproxy_sessions_average | Average number of sessions in HAProxy |
| haproxy_sessions_count | Total number of active sessions in HAProxy |
| haproxy_sessions_rate | Rate of new sessions in HAProxy |