Skip to main content
APA
Sponsored by CAST AI — Kubernetes cost optimization Better Stack — Uptime monitoring and log management
⚠️

Alert thresholds depend on the nature of your applications. Some queries may have arbitrary tolerance thresholds. Building an efficient monitoring platform takes time. 😉

HaProxy Prometheus Alert Rules

30 Prometheus alerting rules for HaProxy. Exported via Embedded exporter (HAProxy >= v2), prometheus/haproxy_exporter (HAProxy < v2). These rules cover critical and warning conditions — copy and paste the YAML into your Prometheus configuration.

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/haproxy/embedded-exporter-v2.yml
critical

4.3.1.1. HAProxy high HTTP 4xx error rate backend

Too many HTTP requests with status 4xx (> 5%) on backend {{ $labels.proxy }}

- alert: HAProxyHighHTTP4xxErrorRateBackend
  expr: ((sum by (proxy) (rate(haproxy_server_http_responses_total{code="4xx"}[1m])) / sum by (proxy) (rate(haproxy_server_http_responses_total[1m]))) * 100) > 5 and sum by (proxy) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 4xx error rate backend (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 4xx (> 5%) on backend {{ $labels.proxy }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.2. HAProxy high HTTP 5xx error rate backend

Too many HTTP requests with status 5xx (> 5%) on backend {{ $labels.proxy }}

- alert: HAProxyHighHTTP5xxErrorRateBackend
  expr: ((sum by (proxy) (rate(haproxy_server_http_responses_total{code="5xx"}[1m])) / sum by (proxy) (rate(haproxy_server_http_responses_total[1m]))) * 100) > 5 and sum by (proxy) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 5xx error rate backend (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 5xx (> 5%) on backend {{ $labels.proxy }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.3. HAProxy high HTTP 4xx error rate server

Too many HTTP requests with status 4xx (> 5%) on server {{ $labels.server }}

- alert: HAProxyHighHTTP4xxErrorRateServer
  expr: ((sum by (server) (rate(haproxy_server_http_responses_total{code="4xx"}[1m])) / sum by (server) (rate(haproxy_server_http_responses_total[1m]))) * 100) > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 4xx error rate server (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 4xx (> 5%) on server {{ $labels.server }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.4. HAProxy high HTTP 5xx error rate server

Too many HTTP requests with status 5xx (> 5%) on server {{ $labels.server }}

- alert: HAProxyHighHTTP5xxErrorRateServer
  expr: ((sum by (server) (rate(haproxy_server_http_responses_total{code="5xx"}[1m])) / sum by (server) (rate(haproxy_server_http_responses_total[1m]))) * 100) > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 5xx error rate server (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 5xx (> 5%) on server {{ $labels.server }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.5. HAProxy server response errors

Too many response errors to {{ $labels.server }} server (> 5%).

- alert: HAProxyServerResponseErrors
  expr: (sum by (server) (rate(haproxy_server_response_errors_total[1m])) / sum by (server) (rate(haproxy_server_http_responses_total[1m]))) * 100 > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy server response errors (instance {{ $labels.instance }})
    description: "Too many response errors to {{ $labels.server }} server (> 5%).\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.6. HAProxy backend connection errors

Too many connection errors to {{ $labels.proxy }} backend (> 100 req/s). Request throughput may be too high.

- alert: HAProxyBackendConnectionErrors
  expr: (sum by (proxy) (rate(haproxy_backend_connection_errors_total[1m]))) > 100
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy backend connection errors (instance {{ $labels.instance }})
    description: "Too many connection errors to {{ $labels.proxy }} backend (> 100 req/s). Request throughput may be too high.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.7. HAProxy server connection errors

Too many connection errors to {{ $labels.proxy }} (> 100 req/s). Request throughput may be too high.

- alert: HAProxyServerConnectionErrors
  expr: (sum by (proxy) (rate(haproxy_server_connection_errors_total[1m]))) > 100
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAProxy server connection errors (instance {{ $labels.instance }})
    description: "Too many connection errors to {{ $labels.proxy }} (> 100 req/s). Request throughput may be too high.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.8. HAProxy backend max active session > 80%

Session limit from backend {{ $labels.proxy }} reached 80% of limit - {{ $value | printf "%.2f"}}%

- alert: HAProxyBackendMaxActiveSession>80%
  expr: (haproxy_backend_current_sessions / haproxy_backend_limit_sessions * 100) > 80 and haproxy_backend_limit_sessions > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy backend max active session > 80% (instance {{ $labels.instance }})
    description: "Session limit from backend {{ $labels.proxy }} reached 80% of limit - {{ $value | printf \"%.2f\"}}%\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.9. HAProxy pending requests

Some HAProxy requests are pending on {{ $labels.proxy }} - {{ $value | printf "%.2f"}}

  # haproxy_backend_current_queue is a gauge (current queue depth), not a counter.
- alert: HAProxyPendingRequests
  expr: sum by (proxy) (haproxy_backend_current_queue) > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy pending requests (instance {{ $labels.instance }})
    description: "Some HAProxy requests are pending on {{ $labels.proxy }} - {{ $value | printf \"%.2f\"}}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.10. HAProxy HTTP slowing down

HAProxy backend max total time is above 1s on {{ $labels.proxy }} - {{ $value | printf "%.2f"}}s

- alert: HAProxyHTTPSlowingDown
  expr: avg by (instance, proxy) (haproxy_backend_max_total_time_seconds) > 1
  for: 1m
  labels:
    severity: warning
  annotations:
    summary: HAProxy HTTP slowing down (instance {{ $labels.instance }})
    description: "HAProxy backend max total time is above 1s on {{ $labels.proxy }} - {{ $value | printf \"%.2f\"}}s\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.11. HAProxy retry high

High rate of retry on {{ $labels.proxy }} - {{ $value | printf "%.2f"}}

- alert: HAProxyRetryHigh
  expr: sum by (proxy) (rate(haproxy_backend_retry_warnings_total[1m])) > 10
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy retry high (instance {{ $labels.instance }})
    description: "High rate of retry on {{ $labels.proxy }} - {{ $value | printf \"%.2f\"}}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.1.12. HAproxy has no alive backends

HAProxy has no alive active or backup backends for {{ $labels.proxy }}

- alert: HAproxyHasNoAliveBackends
  expr: haproxy_backend_active_servers + haproxy_backend_backup_servers == 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAproxy has no alive backends (instance {{ $labels.instance }})
    description: "HAProxy has no alive active or backup backends for {{ $labels.proxy }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.13. HAProxy frontend security blocked requests

HAProxy is blocking requests for security reason

- alert: HAProxyFrontendSecurityBlockedRequests
  expr: sum by (proxy) (rate(haproxy_frontend_denied_connections_total[2m])) > 10
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy frontend security blocked requests (instance {{ $labels.instance }})
    description: "HAProxy is blocking requests for security reason\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.1.14. HAProxy server healthcheck failure

Some server healthcheck are failing on {{ $labels.server }} ({{ $value }} in the last 1m)

- alert: HAProxyServerHealthcheckFailure
  expr: increase(haproxy_server_check_failures_total[1m]) > 2
  for: 0m
  labels:
    severity: warning
  annotations:
    summary: HAProxy server healthcheck failure (instance {{ $labels.instance }})
    description: "Some server healthcheck are failing on {{ $labels.server }} ({{ $value }} in the last 1m)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/haproxy/haproxy-exporter-v1.yml
critical

4.3.2.1. HAProxy down

HAProxy down

- alert: HAProxyDown
  expr: haproxy_up == 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAProxy down (instance {{ $labels.instance }})
    description: "HAProxy down\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.2. HAProxy high HTTP 4xx error rate backend (v1)

Too many HTTP requests with status 4xx (> 5%) on backend {{ $labels.backend }}

- alert: HAProxyHighHTTP4xxErrorRateBackend(v1)
  expr: sum by (backend) (rate(haproxy_server_http_responses_total{code="4xx"}[1m])) / sum by (backend) (rate(haproxy_server_http_responses_total[1m])) * 100 > 5 and sum by (backend) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 4xx error rate backend (v1) (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 4xx (> 5%) on backend {{ $labels.backend }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.3. HAProxy high HTTP 5xx error rate backend (v1)

Too many HTTP requests with status 5xx (> 5%) on backend {{ $labels.backend }}

- alert: HAProxyHighHTTP5xxErrorRateBackend(v1)
  expr: sum by (backend) (rate(haproxy_server_http_responses_total{code="5xx"}[1m])) / sum by (backend) (rate(haproxy_server_http_responses_total[1m])) * 100 > 5 and sum by (backend) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 5xx error rate backend (v1) (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 5xx (> 5%) on backend {{ $labels.backend }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.4. HAProxy high HTTP 4xx error rate server (v1)

Too many HTTP requests with status 4xx (> 5%) on server {{ $labels.server }}

- alert: HAProxyHighHTTP4xxErrorRateServer(v1)
  expr: sum by (server) (rate(haproxy_server_http_responses_total{code="4xx"}[1m]) * 100) / sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 4xx error rate server (v1) (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 4xx (> 5%) on server {{ $labels.server }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.5. HAProxy high HTTP 5xx error rate server (v1)

Too many HTTP requests with status 5xx (> 5%) on server {{ $labels.server }}

- alert: HAProxyHighHTTP5xxErrorRateServer(v1)
  expr: sum by (server) (rate(haproxy_server_http_responses_total{code="5xx"}[1m]) * 100) / sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy high HTTP 5xx error rate server (v1) (instance {{ $labels.instance }})
    description: "Too many HTTP requests with status 5xx (> 5%) on server {{ $labels.server }}\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.6. HAProxy server response errors (v1)

Too many response errors to {{ $labels.server }} server (> 5%).

- alert: HAProxyServerResponseErrors(v1)
  expr: sum by (server) (rate(haproxy_server_response_errors_total[1m]) * 100) / sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 5 and sum by (server) (rate(haproxy_server_http_responses_total[1m])) > 0
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy server response errors (v1) (instance {{ $labels.instance }})
    description: "Too many response errors to {{ $labels.server }} server (> 5%).\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.7. HAProxy backend connection errors (v1)

Too many connection errors to {{ $labels.backend }} backend (> 100 req/s). Request throughput may be too high.

- alert: HAProxyBackendConnectionErrors(v1)
  expr: sum by (backend) (rate(haproxy_backend_connection_errors_total[1m])) > 100
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: HAProxy backend connection errors (v1) (instance {{ $labels.instance }})
    description: "Too many connection errors to {{ $labels.backend }} backend (> 100 req/s). Request throughput may be too high.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.8. HAProxy server connection errors (v1)

Too many connection errors to {{ $labels.server }} server (> 100 req/s). Request throughput may be too high.

- alert: HAProxyServerConnectionErrors(v1)
  expr: sum by (server) (rate(haproxy_server_connection_errors_total[1m])) > 100
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAProxy server connection errors (v1) (instance {{ $labels.instance }})
    description: "Too many connection errors to {{ $labels.server }} server (> 100 req/s). Request throughput may be too high.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.9. HAProxy backend max active session

HAProxy backend {{ $labels.backend }} is reaching session limit (> 80%).

- alert: HAProxyBackendMaxActiveSession
  expr: ((sum by (backend) (haproxy_backend_current_sessions * 100) / sum by (backend) (haproxy_backend_limit_sessions))) > 80 and sum by (backend) (haproxy_backend_limit_sessions) > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy backend max active session (instance {{ $labels.instance }})
    description: "HAProxy backend {{ $labels.backend }} is reaching session limit (> 80%).\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.10. HAProxy pending requests (v1)

Some HAProxy requests are pending on {{ $labels.backend }} backend

- alert: HAProxyPendingRequests(v1)
  expr: sum by (backend) (haproxy_backend_current_queue) > 0
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy pending requests (v1) (instance {{ $labels.instance }})
    description: "Some HAProxy requests are pending on {{ $labels.backend }} backend\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.11. HAProxy HTTP slowing down (v1)

Average request time is increasing

- alert: HAProxyHTTPSlowingDown(v1)
  expr: avg by (backend) (haproxy_backend_http_total_time_average_seconds) > 1
  for: 1m
  labels:
    severity: warning
  annotations:
    summary: HAProxy HTTP slowing down (v1) (instance {{ $labels.instance }})
    description: "Average request time is increasing\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.12. HAProxy retry high (v1)

High rate of retry on {{ $labels.backend }} backend

- alert: HAProxyRetryHigh(v1)
  expr: sum by (backend) (rate(haproxy_backend_retry_warnings_total[1m])) > 10
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy retry high (v1) (instance {{ $labels.instance }})
    description: "High rate of retry on {{ $labels.backend }} backend\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.13. HAProxy backend down

HAProxy backend is down

- alert: HAProxyBackendDown
  expr: haproxy_backend_up == 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAProxy backend down (instance {{ $labels.instance }})
    description: "HAProxy backend is down\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

4.3.2.14. HAProxy server down

HAProxy server is down

- alert: HAProxyServerDown
  expr: haproxy_server_up == 0
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: HAProxy server down (instance {{ $labels.instance }})
    description: "HAProxy server is down\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.15. HAProxy frontend security blocked requests (v1)

HAProxy is blocking requests for security reason

- alert: HAProxyFrontendSecurityBlockedRequests(v1)
  expr: sum by (frontend) (rate(haproxy_frontend_requests_denied_total[2m])) > 10
  for: 2m
  labels:
    severity: warning
  annotations:
    summary: HAProxy frontend security blocked requests (v1) (instance {{ $labels.instance }})
    description: "HAProxy is blocking requests for security reason\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

4.3.2.16. HAProxy server healthcheck failure (v1)

Some server healthcheck are failing on {{ $labels.server }} ({{ $value }} in the last 1m)

- alert: HAProxyServerHealthcheckFailure(v1)
  expr: increase(haproxy_server_check_failures_total[1m]) > 2
  for: 0m
  labels:
    severity: warning
  annotations:
    summary: HAProxy server healthcheck failure (v1) (instance {{ $labels.instance }})
    description: "Some server healthcheck are failing on {{ $labels.server }} ({{ $value }} in the last 1m)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"