Files
FabledSteward/steward/templates/alerts/_history_rows.html
T
bvandeusenandClaude Opus 5.5 531a193bd1
CI / lint (push) Successful in 3s
CI / integration (push) Failing after 54s
CI / unit (push) Successful in 1m34s
CI / publish (push) Skipped
feat(alerts): history reads as episodes; tests follow the confirm dialog (#5316, #5314)
History (#5316):
- Transitions fold into episodes (steward/alerts/episodes.py): each stretch
  out of quiet, the worst state it reached, how long it lasted, its worst
  reading against the rule ('3m 21s (fires above 3m)'), who was told across
  its changes, and its Ansible runs. The changes themselves fold under it.
- An episode cut by paging says so ('cleared later (above)', 'earlier').
- For one rule: a verdict ('Fired 4 times in the last 7d, 1h 2m in all') and
  no Rule column. Notified and Action show only when the range has any.

Tests:
- The confirm guard looks for a confirm( call, not the word in the comment
  that says it is gone (lesson #4365).
- The Hosts viewer test looks for the add-host dialog by id, since every page
  now carries the confirm dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 23:02:01 -04:00

37 lines
1.7 KiB
HTML

{# alerts/_history_rows.html — the history: for one rule, how often it fired
and for how long in all; then its episodes (#5316), swapped in on a range
or rule change. The rule column shows only across rules, Notified and
Action only when the range has something to put in them. Episodes come a
page of transitions at a time (alerts/_history_page.html). #}
{% from "_macros.html" import empty_state %}
{% if chosen and verdict %}
<p class="page-verdict">
{%- if verdict.fired %}<strong class="tone-{{ 'crit' if verdict.ongoing else 'warn' }}">Fired {{ verdict.fired }} time{{ "s" if verdict.fired != 1 }}</strong> in the last {{ current_range }}
{%- if verdict.seconds %}, {{ verdict.seconds|duration }} in all{% endif %}
{%- if verdict.ongoing %} · <span class="tone-crit">firing now</span>{% endif %}
{%- else %}<strong class="tone-ok">Never fired</strong> in the last {{ current_range }}{% endif %}
<span class="tone-dim">· fires when {{ rule_condition(chosen) }} on {{ chosen.resource_name }}</span>
</p>
{% endif %}
{% if episodes %}
<div class="card-flush">
<table class="table alert-episodes">
<thead>
<tr>
<th>When</th>
{% if not chosen %}<th>Rule</th>{% endif %}
<th>What happened</th>
<th title="The reading furthest past the rule's threshold">Worst reading</th>
{% if show_notified %}<th>Notified</th>{% endif %}
{% if show_action %}<th>Action</th>{% endif %}
</tr>
</thead>
<tbody>
{% include "alerts/_history_page.html" %}
</tbody>
</table>
</div>
{% else %}
<div class="card">{{ empty_state("No alert changed state in the last " ~ current_range ~ ((" for " ~ chosen.name) if chosen else "") ~ ".") }}</div>
{% endif %}