Agent offline is an ordinary rule now. The host_agent scheduler records host_agent/<host>/seconds_since_seen every minute (from last_seen_at, or registration time for an agent that never reported), replacing the task that only logged stale agents. The catalog offers the metric, and picking it on a new rule fills "> 180". No data: each rule's state tracks its last sample and its usual gap, smoothed so that an outage counts as at most three gaps. A core task, alert_silence_check, runs every 60s and marks a rule no_data_since once its series has had no sample for three usual gaps (at least 5 minutes; an hour while the cadence is unknown). A never-sampled rule counts from when it started watching. The mark sits beside the state, so a firing alert that goes silent stays firing. Each silence records one event and sends one notification (rule option notify_no_data, default on; muted in maintenance windows). The next sample clears it with a "data resumed" event and notification. Creating, changing, disabling or re-enabling a rule restarts its watch. Migration 0029 adds the columns and seeds each existing rule's last sample and gap from its last day of data, so an upgrade does not flag every rule. Shown on the Alerts page (a NO DATA badge with its start time), in MCP list_alerts, list_alert_rules and get_host (state "no_data", no_data_since), in get_overview findings (alert_no_data, or a firing alert marked silent) and in the weekly report. The rule form has the notify option, and its metric reference now matches what traefik records and lists host_agent. Emails say "no data" and carry the event's note. The metric-catalog guard also reads positional MetricBatch.add arguments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.9 KiB
HTML
112 lines
4.9 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Alerts — Steward{% endblock %}
|
|
{% block content %}
|
|
<h1 class="page-title">Alerts</h1>
|
|
|
|
{% if active %}
|
|
<h2 class="section-title" style="margin-bottom:1rem;">Active</h2>
|
|
<div class="card-flush" style="margin-bottom:2rem;">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>State</th>
|
|
<th>Rule</th>
|
|
<th>Resource</th>
|
|
<th>Metric</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for state, rule in active %}
|
|
<tr>
|
|
<td>
|
|
{% if state.state.value == 'firing' %}
|
|
<span class="badge badge-red">FIRING</span>
|
|
{% elif state.state.value == 'acknowledged' %}
|
|
<span class="badge badge-yellow">ACK</span>
|
|
{% elif state.state.value == 'pending' %}
|
|
<span class="badge badge-dim">PENDING</span>
|
|
{% endif %}
|
|
{% if state.no_data_since %}
|
|
<span class="badge badge-yellow"
|
|
title="No sample since {{ state.last_sample_at.strftime('%Y-%m-%d %H:%M UTC') if state.last_sample_at else 'the rule started watching' }}">NO DATA</span>
|
|
<div style="font-size:0.72rem;color:var(--text-dim);margin-top:0.2rem;">
|
|
since {{ state.no_data_since.strftime("%Y-%m-%d %H:%M") }} UTC
|
|
</div>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ rule.name }}</td>
|
|
<td style="color:var(--text-muted);">{{ rule.resource_name }}</td>
|
|
<td style="color:var(--text-muted);">{{ rule.metric_name }} {{ rule.operator.value }} {{ rule.threshold }}</td>
|
|
<td class="td-actions">
|
|
{% if state.state.value == 'firing' %}
|
|
<form method="post" action="/alerts/{{ rule.id }}/acknowledge" style="display:inline;">{{ csrf_field() }}
|
|
<button type="submit" class="btn btn-sm btn-warn">Acknowledge</button>
|
|
</form>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<p style="color:var(--text-muted);margin-bottom:2rem;">No active alerts.</p>
|
|
{% endif %}
|
|
|
|
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;">
|
|
<h2 class="section-title">Rules</h2>
|
|
<div style="display:flex;gap:0.5rem;">
|
|
<a class="btn btn-ghost" href="/alerts/maintenance">Maintenance</a>
|
|
<a class="btn" href="/alerts/rules/new">New Rule</a>
|
|
</div>
|
|
</div>
|
|
{% if rules %}
|
|
<div class="card-flush">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Condition</th>
|
|
<th style="text-align:center;" title="Checks in a row to fire / to clear">Fire / clear</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for rule in rules %}
|
|
<tr {% if not rule.enabled %}style="opacity:0.55;"{% endif %}>
|
|
<td>
|
|
{{ rule.name }}
|
|
{% if not rule.enabled %}
|
|
<span style="font-size:0.72rem;color:var(--text-dim);margin-left:0.35rem;">disabled</span>
|
|
{% endif %}
|
|
</td>
|
|
<td style="color:var(--text-muted);font-size:0.85rem;">
|
|
<span style="color:var(--text-dim);">{{ rule.source_module }}/</span>{{ rule.resource_name }}
|
|
<span style="font-family:ui-monospace,monospace;font-size:0.8rem;">
|
|
:{{ rule.metric_name }} {{ rule.operator.value }} {{ rule.threshold }}
|
|
</span>
|
|
</td>
|
|
<td style="color:var(--text-muted);text-align:center;">{{ rule.consecutive_failures_required }} / {{ rule.consecutive_ok_required }}</td>
|
|
<td class="td-actions">
|
|
<a href="/alerts/rules/{{ rule.id }}/edit" class="btn btn-sm btn-ghost">Edit</a>
|
|
<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>
|
|
<form method="post" action="/alerts/rules/{{ rule.id }}/delete" style="display:inline;">{{ csrf_field() }}
|
|
<button type="submit" class="btn btn-sm btn-danger"
|
|
onclick="return confirm('Delete rule {{ rule.name }}?')">Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<p style="color:var(--text-muted);">No alert rules configured.</p>
|
|
{% endif %}
|
|
{% endblock %}
|