Files
ottyl/tickets/004-metrics-api.md
T
2026-09-05 12:46:45 +01:00

1.3 KiB

004 — Metrics API

Summary

Expose param/metric declarations and bucket data over HTTP so the frontend (and the filter/dashboard query engines) can declare metrics and read their values.

Scope

  • POST /api/params — declare a param (001).
  • POST /api/metrics — declare a metric (002).
  • GET /api/metrics — list declared metrics (+ their declared params/labels).
  • GET /api/metrics/:name — query bucket values for a metric, filtered by label selector and time/sequence range, mirroring the existing LogsParams/ TimelineParams pattern in dto.rs.
  • Follow the existing engine architecture: new EngineQuery/EngineMessage variants, handled in engine.rs's single-owner loop, DTOs added to dto.rs, routes added to api.rs's router — no new locking or shared state.

Acceptance criteria

  • Declaring a param/metric via the API round-trips through to engine state and shows up in GET /api/metrics.
  • Querying a metric's bucket values supports the same start/end and limit-style params as the existing logs/timeline endpoints.
  • Bad declarations (invalid regex etc.) return a 4xx with a useful error body, not a 500 or silent no-op.

Depends on