feat(metrics): each rolled-up hour keeps the level it held, its p95 (#5738)
plugin_metrics_hourly gains value_p95 beside value_avg and value_max. A two-minute backup spike raises the hour's peak and leaves its p95 low; an hour spent at that level raises both. Learned normals (milestone 513) need that difference to call a recurring spike usual without calling the same level held at another hour usual too. Hours rolled up before this keep a NULL p95 and read as their average. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,22 @@ Core tasks registered in `app._task_registry`:
|
||||
|
||||
---
|
||||
|
||||
## Metric Store
|
||||
|
||||
Every plugin and monitor records into one store keyed by (source, resource, metric):
|
||||
- `plugin_metrics` holds raw samples for `metrics.retention.raw_days` (7 by default).
|
||||
- `plugin_metric_latest` holds each key's newest value.
|
||||
- `data_cleanup` rolls raw samples older than the raw window into `plugin_metrics_hourly`, kept for `metrics.retention.rollup_days` (90 by default).
|
||||
|
||||
Each rolled-up hour keeps three figures:
|
||||
- `value_avg`: the hour's average.
|
||||
- `value_max`: its peak.
|
||||
- `value_p95`: the level it held for all but its briefest 5%, about 3 minutes.
|
||||
|
||||
A two-minute spike raises the peak and leaves the p95 low; an hour spent at that level raises both. Learned normals use this to tell a recurring spike from a held level. Hours rolled up before the p95 was kept have it NULL; read those as their average.
|
||||
|
||||
---
|
||||
|
||||
## Database Session Pattern
|
||||
|
||||
`app.db_sessionmaker` is an SQLAlchemy `async_sessionmaker`. All DB access follows this pattern:
|
||||
|
||||
Reference in New Issue
Block a user