blob: 2d3000a9daf735023fadd548b07ab1b1047d4d66 [file] [log] [blame]
{%- if pillar.haproxy is defined and pillar.haproxy.proxy is defined %}
{%- from "haproxy/map.jinja" import proxy with context %}
{%- if proxy.enabled and proxy.listen is defined and proxy.listen|length > 0 %}
server:
alert:
HaproxyDown:
{% raw %}
if: >-
haproxy_up != 1
labels:
severity: warning
service: haproxy
annotations:
summary: 'Haproxy service down'
description: 'Haproxy service is down on node {{ $labels.host }}'
{% endraw %}
{%- for listen_name, listen in proxy.listen.iteritems() if listen.get('check', True) %}
{%- set camel_case_name = listen_name.replace('-','_').split('_')|map('capitalize')|join('') %}
HAproxy{{ camel_case_name }}HTTPResponse5xx:
{% raw %}
if: >-
rate(haproxy_http_response_5xx{sv="FRONTEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}[1m]) > 1
for: 2m
labels:
severity: warning
service: "haproxy/{{ $labels.proxy }}"
annotations:
summary: HTTP 5xx responses on '{{ $labels.proxy }}' proxy (host {{ $labels.host }})
description: >-
Too many 5xx HTTP errors have been detected on the '{{ $labels.proxy }}' proxy for the last 2 minutes
({{ $value }} error(s) per second)
{% endraw %}
HAproxy{{ camel_case_name }}BackendWarning:
{% raw %}
if: >-
max(max_over_time(haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}[12h])) by (proxy)
- min(haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}) by (proxy) >= 1
for: 5m
labels:
severity: warning
service: "haproxy/{{ $labels.proxy }}"
annotations:
summary: "At least one backend is down for '{{ $labels.proxy }}' proxy for the last 5 minutes"
description: >-
{{ $value }} of backends are down for the '{{ $labels.proxy }}' proxy
{% endraw %}
HAproxy{{ camel_case_name }}BackendCritical:
{% raw %}
if: >-
(max(max_over_time(haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}[12h])) by (proxy)
- min (haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}) by (proxy)
) / max(max_over_time(haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}[12h])) by (proxy) * 100 >= 50
for: 5m
labels:
severity: critical
service: "haproxy/{{ $labels.proxy }}"
annotations:
summary: "Less than 50% of backends are up for the '{{ $labels.proxy }}' proxy for the last 5 minutes"
description: >-
{{ $value }}% of backends are down for the '{{ $labels.proxy }}' proxy
{% endraw %}
HAproxy{{ camel_case_name }}BackendDown:
{% raw %}
if: >-
max(haproxy_active_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}) by (proxy)
+ max(haproxy_backup_servers{sv="BACKEND",proxy="{% endraw %}{{ listen_name }}{% raw %}"}) by (proxy) == 0
for: 2m
labels:
severity: down
service: "haproxy/{{ $labels.proxy }}"
annotations:
summary: "All backends are down for the '{{ $labels.proxy }}' proxy"
description: >-
The proxy '{{ $labels.proxy }}' has no active backend
{% endraw %}
{%- endfor %}
{%- endif %}
{%- endif %}