{% extends "base.html" %} {% from "_macros.html" import crumbs %} {% block title %}{% if rule %}Edit Rule{% else %}New Alert Rule{% endif %} — Steward{% endblock %} {% block breadcrumb %}{{ crumbs([("Alerts", "/alerts/"), ("Edit rule" if rule else "New rule", "")]) }}{% endblock %} {% block content %}

{% if rule %}Edit Rule{% else %}New Alert Rule{% endif %}

{{ csrf_field() }}
{# ── Source module ───────────────────────────────────────────────────── #}
{# ── Dynamic resource + metric ────────────────────────────────────────── #}
{% with current_resource = rule.resource_name if rule else "", current_metric = rule.metric_name if rule else "" %} {% include "alerts/_rule_fields.html" %} {% endwith %}
{# ── Condition: a threshold in the metric's unit, or for an up/down metric the word it fires on (sent as binary_when; the route turns it into < 0.5 or >= 0.5). The script swaps the two as the metric changes. #} {% set m0 = rule.metric_name if rule else "" %} {% set binary = m0 in ("is_up", "is_healthy") %} {% set fires_down = not rule or rule.operator.value in ("<", "<=") %}

A firing or acknowledged alert resolves only after this many checks in a row are back within the threshold. An acknowledgement holds until then.

Silence is always shown as NO DATA on the Alerts page: no sample for three of the metric's usual gaps (at least 5 minutes). This also sends a notification when it starts and when data resumes. A firing alert that goes silent stays firing.

{# ── Metric reference ────────────────────────────────────────────────── #}
What each metric measures
{% for src, names in catalog.items() if names %}
{{ source_label(src) }}
{% for m in names %}
{{ metric_label(m) }}{% if metric_unit(m) %} ({{ metric_unit(m) }}){% endif %} {{ metric_about(m) }}
{% endfor %}
{% endfor %}
{# ── Ansible action (admin only) ─────────────────────────────────────── #} {% if session.get("user_role") == "admin" %} {% set act = rule.ansible_action if rule and rule.ansible_action else None %}

Admin only. Runs once when the alert transitions into FIRING. steward_alert_* context vars (resource, metric, value…) are injected automatically.

{% endif %}
Cancel
{% endblock %}