feat(settings): configurable monitoring thresholds
Move the hardcoded warn/crit cutoffs into Settings -> Thresholds (DB-backed, live, no restart). New thresholds.* keys + to_thresholds_cfg() + a threshold_style(value, kind) jinja global that reads them; latency reuses the existing ping good/warn keys, uptime is direction-aware (floors). Replace the _macros metric_style/uptime_style macros (now removed) with the global across Hosts-Overview, host_agent fleet + panel, Uptime/SLA widget, and the ping page uptime column — all now honor the configured cutoffs. Uptime keeps its green 'good' look when not degraded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,24 +17,6 @@
|
||||
</nav>
|
||||
{%- endmacro %}
|
||||
|
||||
{# Threshold emphasis for a numeric metric (CPU/mem/disk %, etc).
|
||||
Returns an inline-style fragment to drop into a span's style="": amber +
|
||||
semibold at >= warn, red + bold at >= crit, empty (inherit) when the value
|
||||
is normal or None. This makes the FAILING METRIC ITSELF stand out — not just
|
||||
the status dot. Defaults suit percentage gauges (warn 80 / crit 90); pass
|
||||
explicit warn/crit for other scales. Keep thresholds here so they live in one
|
||||
place rather than hardcoded per template. #}
|
||||
{% macro metric_style(value, warn=80, crit=90) -%}
|
||||
{%- if value is not none and value >= crit -%}color:var(--red);font-weight:700;
|
||||
{%- elif value is not none and value >= warn -%}color:var(--yellow);font-weight:600;
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
|
||||
{# Inverted emphasis for "higher is better" metrics like uptime %: amber below
|
||||
`warn`, red below `crit`. The mirror of metric_style — same one-place-for-
|
||||
thresholds discipline, opposite direction. Defaults suit SLA percentages. #}
|
||||
{% macro uptime_style(value, warn=99.0, crit=95.0) -%}
|
||||
{%- if value is not none and value < crit -%}color:var(--red);font-weight:700;
|
||||
{%- elif value is not none and value < warn -%}color:var(--yellow);font-weight:600;
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
{# Metric threshold coloring moved to the `threshold_style(value, kind)` jinja
|
||||
global (steward/core/settings.py + app.py), which reads operator-configurable
|
||||
cutoffs from Settings → Thresholds. Call it as threshold_style(v, 'cpu'). #}
|
||||
|
||||
Reference in New Issue
Block a user