Skip to content

feat(observability): --observability-mode to skip redundant per-instance sidecars - #264

Merged
zheli merged 1 commit into
mainfrom
feat/observability-shared-only
Jul 12, 2026
Merged

feat(observability): --observability-mode to skip redundant per-instance sidecars#264
zheli merged 1 commit into
mainfrom
feat/observability-shared-only

Conversation

@srikanth-bitdynamics

Copy link
Copy Markdown
Collaborator

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 (default auto):

  • auto — serve metrics from the host-shared stack and skip the per-instance
    overlay when the shared stack is reachable; fall back to per-instance otherwise.
  • shared — force shared-only.
  • per-instance — force the dedicated overlay (previous behavior).

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 (?var-instance=<name>) instead of a dead, allocated-but-unbound
per-instance port.

Verification

  • Unit tests for the decision logic, validation, and the Grafana fallback; full
    suite green; gofmt + vet clean.
  • Live end-to-end on Docker Desktop: --observability-mode shared created no
    per-instance Prometheus/Grafana, recorded no dead ports, registered as a shared
    scrape target, and metrics returned the live shared Grafana URL (HTTP 200).

CLI ↔ Web UI parity

The Web UI create path already calls RunUp with the auto default, so instances
created from the UI inherit the same dedup. A UI mode-picker is a follow-up (Phase 2).

Follow-up (Phase 2)

Make shared the default and drop the per-instance overlay entirely once the
shared stack's host.docker.internal scrape path is validated end-to-end on a
native Linux Docker host; add the Web UI mode-picker; label observability status
source as "shared" for shared-only instances.

…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.
@zheli
zheli merged commit d942d92 into main Jul 12, 2026
4 checks passed
@zheli
zheli deleted the feat/observability-shared-only branch July 12, 2026 20: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.

2 participants