fix(prometheus): keep/drop patterns split on any whitespace, and a *_time_seconds value reads as a moment (#6423)
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user