feat: alert rules and active alerts UI
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Alerts — FabledNetMon{% endblock %}
|
||||
{% block content %}
|
||||
<h1 style="color:#c0c0ff;margin-bottom:1.5rem;">Alerts</h1>
|
||||
|
||||
{% if active %}
|
||||
<h2 style="color:#8080ff;margin-bottom:1rem;font-size:1rem;">Active</h2>
|
||||
<div class="card" style="padding:0;margin-bottom:2rem;">
|
||||
<table style="width:100%;border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid #2a2a4a;">
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">State</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Rule</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Resource</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Metric</th>
|
||||
<th style="padding:0.75rem 1rem;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for state, rule in active %}
|
||||
<tr style="border-bottom:1px solid #1a1a3a;">
|
||||
<td style="padding:0.75rem 1rem;">
|
||||
{% if state.state.value == 'firing' %}
|
||||
<span style="color:#ff6060;font-weight:bold;">FIRING</span>
|
||||
{% elif state.state.value == 'acknowledged' %}
|
||||
<span style="color:#ffa040;">ACK</span>
|
||||
{% else %}
|
||||
<span style="color:#a0a0a0;">PENDING</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td style="padding:0.75rem 1rem;">{{ rule.name }}</td>
|
||||
<td style="padding:0.75rem 1rem;color:#a0a0c0;">{{ rule.resource_name }}</td>
|
||||
<td style="padding:0.75rem 1rem;color:#a0a0c0;">{{ rule.metric_name }} {{ rule.operator.value }} {{ rule.threshold }}</td>
|
||||
<td style="padding:0.75rem 1rem;text-align:right;">
|
||||
{% if state.state.value == 'firing' %}
|
||||
<form method="post" action="/alerts/{{ rule.id }}/acknowledge" style="display:inline;">
|
||||
<button type="submit" class="btn" style="background:#605010;">Acknowledge</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="color:#606080;margin-bottom:2rem;">No active alerts.</p>
|
||||
{% endif %}
|
||||
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;">
|
||||
<h2 style="color:#8080ff;font-size:1rem;">Rules</h2>
|
||||
<a class="btn" href="/alerts/rules/new">New Rule</a>
|
||||
</div>
|
||||
{% if rules %}
|
||||
<div class="card" style="padding:0;">
|
||||
<table style="width:100%;border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid #2a2a4a;">
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Name</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Condition</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Consec.</th>
|
||||
<th style="text-align:left;padding:0.75rem 1rem;color:#8080a0;font-weight:normal;">Enabled</th>
|
||||
<th style="padding:0.75rem 1rem;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for rule in rules %}
|
||||
<tr style="border-bottom:1px solid #1a1a3a;">
|
||||
<td style="padding:0.75rem 1rem;">{{ rule.name }}</td>
|
||||
<td style="padding:0.75rem 1rem;color:#a0a0c0;">
|
||||
{{ rule.source_module }}/{{ rule.resource_name }}:{{ rule.metric_name }}
|
||||
{{ rule.operator.value }} {{ rule.threshold }}
|
||||
</td>
|
||||
<td style="padding:0.75rem 1rem;color:#a0a0c0;">{{ rule.consecutive_failures_required }}</td>
|
||||
<td style="padding:0.75rem 1rem;">
|
||||
{% if rule.enabled %}<span style="color:#60c060;">yes</span>{% else %}<span style="color:#606060;">no</span>{% endif %}
|
||||
</td>
|
||||
<td style="padding:0.75rem 1rem;text-align:right;">
|
||||
<form method="post" action="/alerts/rules/{{ rule.id }}/delete" style="display:inline;">
|
||||
<button type="submit" style="background:none;border:none;color:#ff6060;cursor:pointer;"
|
||||
onclick="return confirm('Delete rule {{ rule.name }}?')">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="color:#606080;">No alert rules configured.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user