Files
FabledSteward/steward/templates/settings/thresholds.html
T
bvandeusenandClaude Opus 5.5 96c1ea9407
CI / lint (push) Successful in 5s
CI / integration (push) Successful in 1m8s
CI / unit (push) Successful in 1m34s
CI / publish (push) Successful in 2m27s
feat(host_agent): how far each host's clock is from Steward's (milestone 490)
- Agent 1.12.0 stamps each post with sent_at; ingest compares it with the
  moment the post arrived: clock_offset_s / clock_checked_at on the
  registration (host_agent_003), and a clock_off_secs metric (either way)
  that alert rules can watch. Replaces the old skew log, which measured the
  newest sample and was off by up to an interval.
- Settings -> Thresholds: Clock drift, 30 s warn / 5 min critical.
- Host page: 'clock 0.3s ahead' in the vitals line, toned past the warning.
- Hosts list: names hosts whose clock is off; when every reporting host is
  off by about the same amount, says Steward's own clock is the likely one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 08:00:33 -04:00

157 lines
9.2 KiB
HTML

{# steward/templates/settings/thresholds.html — tunable degraded/critical cutoffs #}
{% extends "base.html" %}
{% from "_macros.html" import crumbs %}
{% block title %}Settings — Thresholds & Retention — Steward{% endblock %}
{% block breadcrumb %}{{ crumbs([("Settings", "/settings/"), ("Thresholds & retention", "")]) }}{% endblock %}
{% block content %}
{% set active_tab = "thresholds" %}
{% include "settings/_tabs.html" %}
{% macro pair(label, warn_field, warn_key, crit_field, crit_key, unit, hint, step="1") %}
<div class="form-group" style="margin-bottom:1.1rem;">
<label>{{ label }} <span style="color:var(--text-muted);font-size:0.8rem;">({{ unit }})</span></label>
<div style="display:flex;gap:1.25rem;flex-wrap:wrap;margin-top:0.25rem;">
<span style="display:flex;align-items:center;gap:0.4rem;">
<span style="color:var(--yellow);font-size:0.8rem;font-weight:500;">warn</span>
<input type="number" name="{{ warn_field }}" step="{{ step }}"
value="{{ settings[warn_key] }}" style="max-width:110px;">
</span>
<span style="display:flex;align-items:center;gap:0.4rem;">
<span style="color:var(--red);font-size:0.8rem;font-weight:500;">crit</span>
<input type="number" name="{{ crit_field }}" step="{{ step }}"
value="{{ settings[crit_key] }}" style="max-width:110px;">
</span>
</div>
{% if hint %}<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">{{ hint }}</div>{% endif %}
</div>
{% endmacro %}
<form method="post" action="/settings/thresholds/">{{ csrf_field() }}
<div class="card" style="max-width:640px;">
<h2 class="section-title" style="margin-bottom:0.5rem;">Monitoring thresholds</h2>
<p style="font-size:0.82rem;color:var(--text-muted);margin-bottom:1.25rem;">
Values at or beyond <span style="color:var(--yellow);">warn</span> show amber; at or beyond
<span style="color:var(--red);">crit</span> show red — across dashboard widgets and host views.
Higher is worse for everything except uptime, where the cutoffs are floors.
</p>
{{ pair("CPU usage", "cpu_warn", "thresholds.cpu_warn", "cpu_crit", "thresholds.cpu_crit", "%", "Average CPU utilization per host.") }}
{{ pair("Memory usage", "mem_warn", "thresholds.mem_warn", "mem_crit", "thresholds.mem_crit", "%", "Memory in use per host.") }}
{{ pair("Disk usage", "disk_warn", "thresholds.disk_warn", "disk_crit", "thresholds.disk_crit", "%", "Filesystem usage.") }}
{{ pair("Load", "load_warn", "thresholds.load_warn", "load_crit", "thresholds.load_crit", "% per core", "Load average normalized by core count (100% = one full core per core).") }}
{{ pair("Temperature", "temp_warn", "thresholds.temp_warn", "temp_crit", "thresholds.temp_crit", "°C", "Hottest reported sensor per host.") }}
{{ pair("Ping latency", "latency_warn", "ping.threshold.good_ms", "latency_crit", "ping.threshold.warn_ms", "ms", "Round-trip time. Shared with the Ping widget's good/warn colouring.") }}
{{ pair("Uptime / SLA", "uptime_warn", "thresholds.uptime_warn", "uptime_crit", "thresholds.uptime_crit", "%", "Lower is worse — amber below warn, red below crit.", step="0.1") }}
{{ pair("TLS certificate expiry", "tls_warn", "thresholds.tls_warn_days", "tls_crit", "thresholds.tls_crit_days", "days left", "HTTPS monitors whose certificate expires within these many days are flagged. Lower is worse.") }}
{{ pair("Clock drift", "clock_warn", "thresholds.clock_warn_s", "clock_crit", "thresholds.clock_crit_s", "seconds", "How far a host's clock may be from Steward's, either way, before its page and the Hosts list call it out.") }}
<div class="form-group" style="margin-bottom:0.25rem;">
<label>Container crash loop <span style="color:var(--text-muted);font-size:0.8rem;">(deaths per hour)</span></label>
<div style="margin-top:0.25rem;">
<input type="number" name="crash_loop_deaths" min="1" step="1"
value="{{ settings['thresholds.crash_loop_deaths'] }}" style="max-width:110px;">
</div>
<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">
A container that dies (or is OOM-killed) this many times within an hour is reported as crash-looping.
</div>
</div>
</div>
{% macro days(label, field, key, hint) %}
<div class="form-group" style="margin-bottom:1.1rem;">
<label>{{ label }} <span style="color:var(--text-muted);font-size:0.8rem;">(days)</span></label>
<div style="margin-top:0.25rem;">
<input type="number" name="{{ field }}" min="1" step="1"
value="{{ settings[key] }}" style="max-width:110px;">
</div>
{% if hint %}<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">{{ hint }}</div>{% endif %}
</div>
{% endmacro %}
<div class="card" style="max-width:640px;margin-top:1.5rem;">
<h2 class="section-title" style="margin-bottom:0.5rem;">Docker data retention</h2>
<p style="font-size:0.82rem;color:var(--text-muted);margin-bottom:1.25rem;">
Bounds how much Docker history is stored. Raw per-sample container metrics are
kept for the raw window, then rolled up into hourly averages kept for the
rollup window; lifecycle events are kept for the events window. Applied by the
hourly cleanup task — a change takes effect on its next run.
</p>
{{ days("Raw metrics", "docker_metrics_raw_days", "docker.retention.metrics_raw_days",
"Keep per-sample container CPU/memory points this long, then roll up to hourly.") }}
{{ days("Rolled-up metrics", "docker_metrics_rollup_days", "docker.retention.metrics_rollup_days",
"Keep the hourly-averaged series this long for multi-day history.") }}
{{ days("Lifecycle events", "docker_events_days", "docker.retention.events_days",
"Keep container start/stop/die/health history this long.") }}
</div>
<div class="card" style="max-width:640px;margin-top:1rem;">
<h2 class="section-title" style="margin-bottom:0.5rem;">Container logs</h2>
<p style="font-size:0.82rem;color:var(--text-muted);margin-bottom:1.25rem;">
The host agent tails each container's logs and pushes them here, viewable per
container. On by default for every container; storage is bounded by a
per-container ring (oldest lines rotate out once the age or size cap is hit,
whichever comes first). Applied by the hourly cleanup and on ingest.
</p>
<div class="form-group" style="margin-bottom:1.1rem;">
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
<input type="checkbox" name="docker_logs_enabled" style="width:auto;"
{% if settings["docker.logs.enabled"] %}checked{% endif %}>
Collect container logs
</label>
<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">
Global kill-switch. When off, pushed log lines are dropped and no new logs are stored.
</div>
</div>
<div class="form-group" style="margin-bottom:1.1rem;">
<label>Exclude containers</label>
<div style="margin-top:0.25rem;">
<input type="text" name="docker_logs_exclude"
value="{{ settings['docker.logs.exclude'] | join(', ') }}"
placeholder="watchtower, some-chatty-service" style="width:100%;max-width:420px;">
</div>
<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">
Comma-separated container names whose logs are dropped on ingest (e.g. known-noisy ones).
</div>
</div>
{{ days("Log retention", "docker_logs_retention_days", "docker.logs.retention_days",
"Keep each container's log lines at most this long before rotating them out.") }}
<div class="form-group" style="margin-bottom:0.25rem;">
<label>Max size per container <span style="color:var(--text-muted);font-size:0.8rem;">(MB)</span></label>
<div style="margin-top:0.25rem;">
<input type="number" name="docker_logs_max_mb" min="1" step="1"
value="{{ (settings['docker.logs.max_bytes_per_container'] // 1000000) or 1 }}"
style="max-width:110px;">
</div>
<div style="font-size:0.78rem;color:var(--text-muted);margin-top:0.3rem;">
Newest lines are kept up to this size per container; older lines rotate out first.
</div>
</div>
</div>
<div class="card" style="max-width:640px;margin-top:1rem;">
<h2 class="section-title" style="margin-bottom:0.5rem;">Host metrics retention</h2>
<p style="font-size:0.82rem;color:var(--text-muted);margin-bottom:1.25rem;">
Bounds how much host-agent metric history is stored (CPU, memory, disk, network,
temps, …). Raw per-sample points are kept for the raw window, then rolled up
into hourly averages kept for the rollup window. Host charts read raw for the
recent part of a range and hourly for older data. Applied by the hourly cleanup.
</p>
{{ days("Raw metrics", "metrics_raw_days", "metrics.retention.raw_days",
"Keep per-sample host metrics this long, then roll up to hourly averages.") }}
{{ days("Rolled-up metrics", "metrics_rollup_days", "metrics.retention.rollup_days",
"Keep the hourly-averaged series this long for multi-week history.") }}
</div>
<div style="margin-top:1rem;display:flex;align-items:center;gap:1rem;">
<button type="submit" class="btn">Save</button>
<span style="font-size:0.82rem;color:var(--text-muted);">Takes effect immediately — no restart.</span>
</div>
</form>
{% endblock %}