feat(observability): --observability-mode to skip redundant per-instance sidecars - #264
Merged
Conversation
…nce sidecars Every observability-enabled LocalNet also spun up its own Prometheus+Grafana overlay on top of the host-shared stack, so N instances ran N+1 of each — pure duplication that wastes ~600 MiB per environment and pressures a memory-capped Docker host. `up --observability-mode auto|shared|per-instance` (default auto) now prefers the shared stack and skips the per-instance overlay when it is reachable; per-instance remains the platform-independent fallback. The mode is persisted so a re-up preserves it. When the overlay is skipped the metrics/dashboard links resolve to the shared Grafana (filtered to the instance) rather than a dead, allocated-but-unbound per-instance port. Making shared the default and dropping the overlay entirely waits on validating the shared stack's host.docker.internal scrape path on native Linux; until then auto covers Docker Desktop and per-instance is the escape hatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every observability-enabled LocalNet spun up its own Prometheus + Grafana
overlay on top of the host-shared stack, so N instances ran N+1 of each —
pure duplication (~600 MiB per environment) that pressures a memory-capped
Docker host. There was no way to opt out.
Change
localnet up --observability-mode auto|shared|per-instance(defaultauto):overlay when the shared stack is reachable; fall back to per-instance otherwise.
The mode is persisted, so a re-up preserves it. When the overlay is skipped, the
metrics/ dashboard links resolve to the shared Grafana filtered to theinstance (
?var-instance=<name>) instead of a dead, allocated-but-unboundper-instance port.
Verification
suite green; gofmt + vet clean.
--observability-mode sharedcreated noper-instance Prometheus/Grafana, recorded no dead ports, registered as a shared
scrape target, and
metricsreturned the live shared Grafana URL (HTTP 200).CLI ↔ Web UI parity
The Web UI create path already calls
RunUpwith theautodefault, so instancescreated from the UI inherit the same dedup. A UI mode-picker is a follow-up (Phase 2).
Follow-up (Phase 2)
Make
sharedthe default and drop the per-instance overlay entirely once theshared stack's
host.docker.internalscrape path is validated end-to-end on anative Linux Docker host; add the Web UI mode-picker; label
observability statussource as "shared" for shared-only instances.