Skip to content

mvp phase ε.2: register prometheus_remote engine in EngineRouter - #103

Merged
zzylol merged 1 commit into
mainfrom
mvp/phase-eps.2-backend-prometheus-remote-engine
May 7, 2026
Merged

zzylol merged 1 commit into
mainfrom
mvp/phase-eps.2-backend-prometheus-remote-engine

Conversation

@zzylol

@zzylol zzylol commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds PrometheusForwardEngine (HTTP-forwarder to Prometheus's standard /api/v1/query) and registers it on the capability router under data_source_id = prometheus_remote when ASAP_PROMETHEUS_QUERY_URL is set. Wired into both src/main.rs and src/bin/precompute_engine.rs. Mirror of Step-2.3's ThanosForwardEngine (PR mvp step 2.3: backend HTTP-forward to thanos-query for Path A2 archive #97), pointed at Prometheus instead of a thanos-query sidecar.
  • Adds StorageBackend::PrometheusRemote (data_source_id = "prometheus_remote") to asap_types::capability_matching so compatible_storage_backends returns [PrometheusRemote] for Mode 3 metrics (single backend, no failover — the metric's data never landed in ASAP-managed storage). parse_engine_string in BackendStorageRouting accepts the controller's engine: prometheus_remote string.
  • Fail-loud contract: env unset → engine not registered → routing entry referencing prometheus_remote returns NoEngineRegistered. Engine reachable but Prometheus down → Backend(prometheus_unreachable: ...) → 503 with data_source_quirk: prometheus_unreachable in the response infos.

Context

Phase ε.1 (controller, separate repo) emits engine: prometheus_remote in the BackendStorageRouting JSON for metrics whose raw data is shipped to Prometheus's native OTLP receiver (controller's RawAtEdgePrometheusArchive mode). Phase ε.2 (this PR) closes the loop by registering an engine that handles those routing entries. Existing thanos_archive / gorilla_archive registrations are unchanged.

Test plan

  • cargo build --release — green
  • cargo test --release --lib — 33 pre-existing backend failures unchanged; +17 new tests (12 in engines::prometheus::forward::tests, 3 in routing::backend_storage_routing::tests, 2 in routing::engine_router::tests) all pass
  • HTTP forward path (mock Prometheus axum server)
  • Unreachable upstream → 503 with quirk infos
  • Env-set vs env-unset registration contract
  • Routing-table JSON engine: prometheus_remote parses to StorageBackend::PrometheusRemote
  • Router dispatches StorageBackend::PrometheusRemote to the registered engine; missing-engine surfaces NoEngineRegistered

🤖 Generated with Claude Code

Adds a `PrometheusForwardEngine` (HTTP-forwarder to Prometheus's
`/api/v1/query`) under the `prometheus_remote` engine id so the
controller's Mode 3 (`RawAtEdgePrometheusArchive`) routing entries
have a dispatchable target on the backend. Mirror of Step-2.3's
`ThanosForwardEngine` (PR #97), pointed at Prometheus's standard
HTTP API instead of a thanos-query sidecar.

Wiring is conditional on `ASAP_PROMETHEUS_QUERY_URL`: when set, the
binary registers the engine on the capability router (both `main.rs`
and `bin/precompute_engine.rs`); when unset, the engine is not
registered and a routing-table entry that references
`prometheus_remote` surfaces a clean `NoEngineRegistered` 503 from
the HTTP handler — the correct fail-loud behaviour for a
misconfigured deploy. Phase ε.1 (controller, separate repo) emits
`engine: prometheus_remote` in the `BackendStorageRouting` JSON;
this PR closes the loop by accepting that string in
`parse_engine_string` and resolving it to the new
`StorageBackend::PrometheusRemote` variant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit d5dea3f into main May 7, 2026
@zzylol
zzylol deleted the mvp/phase-eps.2-backend-prometheus-remote-engine branch May 9, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant