#5464 "Group rules: one rule covers every host, or every host in a group", step 2 of milestone 499 "Alerts you can trust". Each rule named one host, so the live instance carried six rules for three hosts, and a new host had no agent-offline or disk alert until someone copied them. - alert_rules.covers / cover_group / parent_id (migration 0041). A rule on host_agent may cover "all_hosts" or a "group" (an inventory group: the Hosts ruling, #5294). A covering rule has no state; Steward keeps one ordinary child rule per covered host, named "<rule>: <host>", so each host's alert keeps its own state, history and acknowledgement. - alerts.service.reconcile_children: a covered host that has reported in the last 7 days gets a child; a host no longer covered loses its child; children take the parent's condition, checks, notify setting, action and on/off. Run on save and each minute (alert_reconcile). - A child is changed through its parent: edit, toggle and delete of a child are refused (409 / PartOfCoveringRule); its edit page opens the parent. - Rule form: a Covers choice for host sources, with the group picker; fixed once the rule exists. Rules list: a covering rule reads "every host in swarm · 3 hosts" with its hosts' rules nested under it, each opening its history. The history picker and the rule count leave covering rules out. - MCP: create_alert_rule takes covers/group; update_alert_rule takes group and passes changes down; list_alert_rules shows covers, hosts and part_of. - docs/core/alerting.md: "Rules that cover hosts". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
5.4 KiB
HTML
99 lines
5.4 KiB
HTML
{# alerts/list.html — the Alerts page (#5315): the verdict and what is active
|
|
(alerts/_active.html, polled), then every rule: what it is doing now and
|
|
when it last fired, what it fires on, and its History and Disable. The
|
|
whole row opens the rule (.row-link, its name is the link); deleting one is
|
|
on its own page, behind the confirm dialog. A rule covering hosts (#5464)
|
|
lists its per-host rules under it; each opens its history. #}
|
|
{% extends "base.html" %}
|
|
{% block title %}Alerts — Steward{% endblock %}
|
|
{% from "_macros.html" import page_header, status_badge, empty_state %}
|
|
{% block content %}
|
|
{% set can_edit = session.user_role in ('operator', 'admin') %}
|
|
{% set rules_total = rules|length %}
|
|
{% set rules_off = rules|rejectattr("enabled")|list|length %}
|
|
{% call page_header("Alerts") %}
|
|
<a class="btn btn-ghost" href="/alerts/history">History</a>
|
|
<a class="btn btn-ghost" href="/alerts/maintenance">Maintenance</a>
|
|
{% if can_edit %}<a class="btn" href="/alerts/rules/new">New rule</a>{% endif %}
|
|
{% endcall %}
|
|
|
|
{# The verdict and Active section re-read themselves, so an alert that clears
|
|
or starts shows without a reload. #}
|
|
<div id="alerts-active" hx-get="/alerts/active" hx-trigger="every {{ poll_interval or 60 }}s" hx-swap="innerHTML">
|
|
{% include "alerts/_active.html" %}
|
|
</div>
|
|
|
|
<h2 class="section-title" style="margin:1.5rem 0 1rem;">Rules</h2>
|
|
{% if rules %}
|
|
<div class="card-flush">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Now</th>
|
|
<th>Fires when</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for rule in rules %}
|
|
{% set kids = (children or {}).get(rule.id, []) %}
|
|
{% set fired = (last_fired or {}).get(rule.id) %}
|
|
<tr class="row-link{% if not rule.enabled %} row-off{% endif %}">
|
|
<td class="cell-name">
|
|
<a class="row-target" href="{{ ('/alerts/rules/' ~ rule.id ~ '/edit') if can_edit else ('/alerts/history?rule=' ~ rule.id) }}" title="{{ rule.name }}">{{ rule.name }}</a>
|
|
<div class="cell-sub">{{ source_label(rule.source_module) }}
|
|
{%- if rule.covers != "resource" %} · {{ kids|length }} host{{ "s" if kids|length != 1 }}{% endif %}</div>
|
|
</td>
|
|
<td>
|
|
{%- set now_label = (rule_state or {}).get(rule.id) %}
|
|
{%- if not rule.enabled %}<span class="tone-dim">off</span>
|
|
{%- elif now_label and now_label not in ('inactive', 'resolved') %}{{ status_badge(now_label) }}
|
|
{%- else %}<span class="tone-ok" title="Within its threshold">quiet</span>{% endif -%}
|
|
<div class="cell-sub">{% if fired %}last fired {{ fired|ago }}{% else %}never fired{% endif %}</div>
|
|
</td>
|
|
<td>
|
|
{% if rule.covers == "group" %}every host in {{ rule.cover_group }}{% elif rule.covers == "all_hosts" %}every host{% else %}{{ rule.resource_name }}{% endif %} · {{ rule_condition(rule) }}
|
|
<div class="cell-sub">
|
|
{%- set n_fire, n_ok = rule.consecutive_failures_required, rule.consecutive_ok_required %}
|
|
{%- if n_fire > 1 %}after {{ n_fire }} checks in a row{% else %}on the first check{% endif %}
|
|
{%- if n_ok > 1 %}; clears after {{ n_ok }} good ones{% endif -%}
|
|
</div>
|
|
</td>
|
|
<td class="td-actions">
|
|
{% if rule.covers == "resource" %}<a href="/alerts/history?rule={{ rule.id }}" class="btn btn-sm btn-ghost">History</a>{% endif %}
|
|
{% if can_edit %}
|
|
<form method="post" action="/alerts/rules/{{ rule.id }}/toggle" style="display:inline;">{{ csrf_field() }}
|
|
<button type="submit" class="btn btn-sm btn-ghost">
|
|
{% if rule.enabled %}Disable{% else %}Enable{% endif %}
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% for kid in kids %}
|
|
{% set kid_label = (rule_state or {}).get(kid.id) %}
|
|
{% set kid_fired = (last_fired or {}).get(kid.id) %}
|
|
<tr class="row-link row-child{% if not kid.enabled %} row-off{% endif %}">
|
|
<td class="cell-name">
|
|
<a class="row-target" href="/alerts/history?rule={{ kid.id }}" title="{{ kid.name }}">{{ kid.resource_name }}</a>
|
|
</td>
|
|
<td>
|
|
{%- if not kid.enabled %}<span class="tone-dim">off</span>
|
|
{%- elif kid_label and kid_label not in ('inactive', 'resolved') %}{{ status_badge(kid_label) }}
|
|
{%- else %}<span class="tone-ok" title="Within its threshold">quiet</span>{% endif -%}
|
|
<div class="cell-sub">{% if kid_fired %}last fired {{ kid_fired|ago }}{% else %}never fired{% endif %}</div>
|
|
</td>
|
|
<td class="tone-dim">as above</td>
|
|
<td class="td-actions"><a href="/alerts/history?rule={{ kid.id }}" class="btn btn-sm btn-ghost">History</a></td>
|
|
</tr>
|
|
{% endfor %}
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="card">{{ empty_state("No alert rules yet.", "New rule" if can_edit else none, "/alerts/rules/new" if can_edit else none) }}</div>
|
|
{% endif %}
|
|
{% endblock %}
|