Under an hour |ago says "12m 3s ago", so the test looks for the minutes alone; the reading cell drops an empty class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
3.0 KiB
HTML
59 lines
3.0 KiB
HTML
{# alerts/widget.html — the dashboard Alerts widget (#5510), in the widget
|
|
shape (snippet #5259): a verdict; what is firing or silent, its reading
|
|
now against what the rule fires on, and since when; then what someone has
|
|
acknowledged, by whom and when; a line when alert email is failing or
|
|
retrying; the quiet rules counted. Rows come from alert_svc.active_rows,
|
|
so they read in the Alerts page's order. #}
|
|
{% from "_macros.html" import status_dot %}
|
|
{% set firing = rows|selectattr("label", "equalto", "firing")|list|length %}
|
|
{% if not total and not rows %}
|
|
<div class="w-verdict" style="color:var(--text-muted);">
|
|
No alert rules yet.{% if session.user_role in ('operator', 'admin') %} <a href="/alerts/rules/new">Add a rule →</a>{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<div class="w-verdict {{ 'tone-crit' if firing else ('tone-warn' if rows else 'tone-ok') }}">
|
|
{%- if firing %}{{ firing }} firing{% else %}Nothing firing{% endif %}
|
|
{%- for key, word in (("no_data", "silent"), ("acknowledged", "acknowledged"), ("pending", "pending")) %}
|
|
{%- set n = rows|selectattr("label", "equalto", key)|list|length %}
|
|
{%- if n %}, {{ n }} {{ word }}{% endif %}
|
|
{%- endfor %}
|
|
{%- if not rows %}: {{ "the rule is" if total == 1 else "all " ~ total ~ " rules are" }} quiet{% endif %}.
|
|
</div>
|
|
{% if rows %}
|
|
<table class="w-table">
|
|
<colgroup><col><col style="width:5rem"><col style="width:5.5rem"></colgroup>
|
|
<thead><tr><th>Alert</th><th>Now</th><th>Since</th></tr></thead>
|
|
<tbody>
|
|
{% for r in rows %}
|
|
{% set rule = r.rule %}
|
|
<tr>
|
|
<td class="w-name" title="{{ rule.name }} · {{ rule.resource_name }}">
|
|
{{- status_dot(r.label) -}}
|
|
{% if session.user_id %}<a href="/alerts/history?rule={{ rule.id }}">{{ rule.name }}</a>{% else %}{{ rule.name }}{% endif %}
|
|
{%- if r.label == "acknowledged" %}
|
|
<span class="w-sub">{{ rule.resource_name }} · acknowledged{% if r.acked_by %} by {{ r.acked_by }}{% endif %}{% if r.state.acknowledged_at %} {{ r.state.acknowledged_at|ago }}{% endif %}</span>
|
|
{%- elif r.label == "no_data" %}
|
|
<span class="w-sub tone-warn">{{ rule.resource_name }} · no reading</span>
|
|
{%- else %}
|
|
<span class="w-sub">{{ rule.resource_name }} · fires on {{ r.condition }}</span>
|
|
{%- endif %}
|
|
</td>
|
|
<td{% if r.label in ("firing", "pending") %} class="{{ 'tone-crit' if r.label == 'firing' else 'tone-warn' }}"{% endif %}>
|
|
{%- if r.label == "no_data" %}—{% else %}{{ metric_value(rule.metric_name, r.value) }}{% endif -%}
|
|
</td>
|
|
<td>{% if r.since %}{{ r.since|ago }}{% else %}—{% endif %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% endif %}
|
|
{% if email.said %}
|
|
<div class="{{ 'tone-crit' if email.failed else 'tone-warn' }}" style="font-size:0.75rem;margin-top:0.4rem;">
|
|
{{- email.said }}{% if session.user_role == "admin" %} — <a href="/settings/system/">Outgoing email</a>{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% if rows and quiet %}
|
|
<div class="w-more">+{{ quiet }} rule{{ "s" if quiet != 1 }} quiet{% if session.user_id %} — <a href="/alerts/">Alerts</a>{% endif %}</div>
|
|
{% endif %}
|
|
{% endif %}
|