{# alerts/_active.html — the Alerts page's verdict and Active section, polled on their own (#5315): one line that says what is firing, how many rules there are and where their notifications go; then the alerts themselves, firing first, then no data, then acknowledged, then pending (alert_svc.active_rows). An acknowledged alert says how long it has been breaching, and apart from that who acknowledged it and when. #} {% from "_macros.html" import status_badge %} {% set can_edit = session.user_role in ('operator', 'admin') %} {% set words = {"firing": "firing", "no_data": "silent", "acknowledged": "acknowledged", "pending": "pending"} %}

{%- set firing = active|selectattr("label", "equalto", "firing")|list|length %} {%- if firing %}{{ firing }} firing {%- elif active %}Nothing is firing {%- else %}Nothing is firing{% endif %} {%- for key in ("no_data", "acknowledged", "pending") %} {%- set n = active|selectattr("label", "equalto", key)|list|length %} {%- if n %} · {{ n }} {{ words[key] }}{% endif %} {%- endfor %} {%- if rules_total %} · {{ rules_total }} rule{{ "s" if rules_total != 1 }}{% if rules_off %}, {{ rules_off }} off{% endif %}{% endif %} {%- if notify %} · notifies {{ notify|join(" and ") }} {%- else %} · notifies nobody yet {%- if session.user_role == 'admin' %} — set up email or a webhook{% endif %}{% endif %}

{% if active %}

Active

{% for row in active %} {% endfor %}
State What is wrong Rule
{{ status_badge(row.label, title=("No sample since " ~ (row.state.last_sample_at.strftime('%Y-%m-%d %H:%M UTC') if row.state.last_sample_at else 'the rule started watching')) if row.label == 'no_data' else none) }} {% if row.state.no_data_since and row.label != 'no_data' %} {{ status_badge('no_data', title="Silent since " ~ row.state.no_data_since.strftime('%Y-%m-%d %H:%M UTC')) }} {% endif %} {{- row.says.lead -}} {%- if row.url %}{{ row.says.resource }}{% else %}{{ row.says.resource }}{% endif -%} {{- row.says.tail -}} {%- if row.label == 'acknowledged' and row.state.acknowledged_at %}
Acknowledged{% if row.acked_by %} by {{ row.acked_by }}{% endif %} {{ row.state.acknowledged_at|ago }}
{%- endif %}
{{ row.rule.name }} {% if can_edit and row.state.state.value == 'firing' %}
{{ csrf_field() }}
{% endif %}
{% endif %}