fix(prometheus): keep/drop patterns split on any whitespace, and a *_time_seconds value reads as a moment (#6423)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m46s
CI / integration (push) Successful in 1m48s
CI / publish (push) Successful in 19s

A pasted drop list whose line breaks had become spaces was stored as one
pattern that matched nothing, so Home Assistant's two 526-series
bookkeeping families filled the 1,000-series cap. No metric name holds
whitespace, so patterns now split on spaces and tabs as well as lines
and commas.

Home Assistant names its Unix times *_time_seconds (e.g.
homeassistant_last_updated_time_seconds), which read as "20751d 21h".
is_moment() takes both suffixes, for the value shown and the chart axis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 19:01:21 -04:00
co-authored by Claude Opus 5.5
parent 057c95c45e
commit 57b2aafd1a
5 changed files with 29 additions and 10 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ from steward.models.users import UserRole
from . import library
from .models import PrometheusTarget, PrometheusWidgetTemplate
from .scraper import ScrapeError, scrape
from .service import (OWN_METRICS, SOURCE, FormError, fold_states, form_values, map_families,
from .service import (OWN_METRICS, SOURCE, FormError, fold_states, form_values, is_moment, map_families,
parse_form, patterns, shown_value, target_state)
prometheus_bp = Blueprint("prometheus", __name__, template_folder="templates")
@@ -325,7 +325,7 @@ async def series_detail(target_id: str):
series = await points(db, SOURCE, resource, metric,
datetime.now(timezone.utc) - timedelta(hours=hours))
labels = resource[len(target.name) + 1:] if resource != target.name else ""
stamp_axis = metric.endswith("_timestamp_seconds")
stamp_axis = is_moment(metric)
return await render_template(
"prometheus/series.html", target=target, resource=resource, metric=metric, labels=labels,
now=shown_value(metric, now_row.value if now_row else None), hours=hours, ranges=RANGES,