Skip to content

feat: add observability proxy - #3332

Merged
floreks merged 26 commits into
masterfrom
sebastian/prod-4541-add-observability-proxy
Mar 19, 2026
Merged

feat: add observability proxy#3332
floreks merged 26 commits into
masterfrom
sebastian/prod-4541-add-observability-proxy

Conversation

@floreks

@floreks floreks commented Mar 17, 2026

Copy link
Copy Markdown
Member

This pull request introduces a new Observability Proxy service to the Console project, providing infrastructure and configuration for deploying, building, and managing the proxy alongside the main application. The changes include Helm chart templates, Kubernetes manifests, CI/CD workflows, and supporting configuration for the new service, as well as updates to network policies and service definitions. The Observability Proxy is designed to handle observability-related traffic and integrates with the Console via gRPC.

Observability Proxy Integration

  • Added Helm chart templates for the Observability Proxy, including deployment.yaml, service.yaml, and hpa.yaml, enabling deployment, service exposure, and autoscaling for the proxy. [1] [2] [3]
  • Introduced configuration options in values.yaml to control proxy deployment, resource allocation, autoscaling, and connection settings.

CI/CD Workflow Enhancements

  • Added new GitHub Actions workflows for CI (observability-proxy-ci.yaml) and CD (observability-proxy-cd.yaml) to automate testing, building, and publishing of the Observability Proxy Docker images for multiple architectures. [1] [2]

Kubernetes Networking and Routing

  • Updated ingress.yaml to route observability endpoints (/ext/v1/ingest, /ext/v1/query) to the Observability Proxy service when enabled.
  • Added a dedicated NetworkPolicy template to restrict access to internal Console ports, including the new gRPC port and proxy ports, with configuration exposed in values.yaml. [1] [2]

Console Service and Deployment Updates

  • Added gRPC port configuration to Console's deployment and service templates to support communication with the Observability Proxy. [1] [2]

Supporting Files

  • Added the Observability Proxy module to go.work and provided a .gitignore and Dockerfile for building and packaging the proxy. [1] [2] [3]

Test Plan

Chart: oci://ghcr.io/pluralsh/console-chart
Name: console
Version: 0.0.0_pr-3332

image:
    tag: pr-3332
    imagePullPolicy: Always
...
observabilityProxy:
    enabled: true
    image:
        tag: pr-3332
        pullPolicy: Always

Checklist

  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a meaningful title and summary to convey the impact of this PR to a user.

Plural Flow: console

michaeljguarino and others added 2 commits March 17, 2026 00:23
This will give two things:

* eliminate libclusters use of the endpoints api that will be deprecated in kubernetes
* still provide cluster discovery in a way that aligns w/ k8s readiness probes (which is when it is added to the headless service)
…nd Helm chart configuration

- Introduced the observability-proxy with logging guidelines, Docker configuration, and endpoints.
- Set up CI/CD workflows for testing, building, and publishing Docker images.
- Added the observability-proxy to the Helm charts, including deployment, service, and horizontal pod autoscaler configurations.
- Implemented initial tests for proxy targets, rate limiting, and HTTP handlers.
@floreks floreks self-assigned this Mar 17, 2026
@floreks
floreks requested a review from a team as a code owner March 17, 2026 12:20
@floreks floreks added the enhancement New feature or request label Mar 17, 2026
@linear

linear Bot commented Mar 17, 2026

Copy link
Copy Markdown

@floreks
floreks marked this pull request as draft March 17, 2026 12:20
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
@pluralsh pluralsh deleted a comment from greptile-apps Bot Mar 17, 2026
floreks added 13 commits March 17, 2026 13:28
…environments`

- Added new Prometheus remote write test environment in `docker-compose.yml`.
- Refactored mock services to support environment variable overrides for flexibility.
- Updated `README.md` with instructions for running E2E tests.
- Included scripts for Prometheus configuration and added relevant test cases for Prometheus path mapping in handler tests.
- Improved reverse proxy logic to correctly set URLs directly in handler.go.
… config

- Introduced `MeterMetrics` gRPC method for reporting metering metrics.
- Enhanced Prometheus remote write configurations with queue settings.
- Updated `docker-compose.yml` and `prom-remote-write.sh` with new parameters.
- Simplified `README.md` and linked out detailed documentation.
- Added tests for Prometheus request byte counting and updated handler logic.
…on for error handling

- Moved main logic into a `run()` function for better error handling and readability in `proxy` and `mock-console`.
- Simplified error propagation with `fmt.Errorf()` instead of immediate `os.Exit()`.
- Optimized `TrimPrefix` logic in `targets.go`.
…cker-compose

- Added `elastic-bulk-write` service to `docker-compose.yml` for posting bulk data to Elastic.
- Updated `README.md` and `development.md` with new Elastic bulk write flow.
- Provided environment variable configuration options for the Elastic service.
…es and optimization flags

- Added `TARGETOS` and `TARGETARCH` arguments for customizable build targets.
- Enabled binary size optimization with `-trimpath` and stripped debug symbols using `-ldflags="-s -w"`.
@floreks

floreks commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

@greptileai review this PR. ES/Prom credentials are ignored intentionally. Clients are reponsible for sending credentials in requests to proxy.

@greptile-apps

greptile-apps Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a new Observability Proxy service — a Go reverse proxy that sits in front of Prometheus (VictoriaMetrics) and Elasticsearch backends, fetches credentials and host configuration from Console via gRPC, and meters ingested bytes back to Console. It ships with Helm chart templates (Deployment, Service, HPA, NetworkPolicy, Ingress routing), multi-arch CI/CD GitHub Actions workflows, and a complete Go module under go/observability-proxy/.

Several issues flagged in earlier review rounds have been addressed in this revision: the thundering-herd on config-cache expiry is solved with singleflight, the usage-reporter goroutine is properly drained before grpcClient.Close() via a done channel, the WriteTimeout is set to 60 s, method guards are present on all proxy endpoints, and the upload/download artifact versions are aligned in both workflows.

Remaining observations:

  • The observability-proxy Deployment uses serviceAccountName: console, inheriting the Console service account's RBAC permissions. The proxy needs no Kubernetes API access, so a dedicated empty service account would be more appropriate.
  • forward() in handler.go allocates a new httputil.ReverseProxy struct (and closure) on every request. Since the Transport and ErrorHandler are constant, a shallow copy of a pre-built base proxy would avoid the per-request allocation on the hot path.
  • Port 50051 is added to charts/console/templates/service.yaml unconditionally (not gated on observabilityProxy.enabled), while the NetworkPolicy that restricts access to it is gated on the separate networkPolicy.consoleInternalPorts.enabled flag (defaults true). These two flags should be documented as a pair, or the service port exposure should be tied to observabilityProxy.enabled.

Confidence Score: 4/5

  • Safe to merge with minor follow-up; no critical bugs or security regressions introduced.
  • Core Go logic is well-tested (singleflight deduplication, byte-counting, method guards, graceful shutdown all have tests or have been verified in code). Previously critical issues (undefined flags, reporter race, artifact version mismatch, write timeout) are resolved. Remaining concerns are a least-privilege service account and a per-request allocation — neither blocks correctness or security in the current deployment model.
  • charts/console/templates/observability-proxy/deployment.yaml (service account), go/observability-proxy/internal/proxy/handler.go (per-request ReverseProxy allocation)

Important Files Changed

Filename Overview
go/observability-proxy/internal/proxy/handler.go Core proxy logic with method guards, metering via countingReadCloser, and upstream error handling. A new ReverseProxy is allocated per request; the Transport is shared correctly. Query-string forwarding is preserved through the Rewrite func.
go/observability-proxy/internal/console/provider.go Caching config provider with singleflight deduplication (addressing thundering-herd on TTL boundaries), stale-cache fallback on refresh errors, and a dedicated mutex. Context is intentionally discarded so refresh is not cancelled by individual request contexts.
go/observability-proxy/internal/metering/meter.go Atomic byte accumulator that periodically flushes to Console. Failed flushes re-queue bytes correctly. Success log fires only on the non-error path. Final flush is correctly awaited before process exit via the reporterDone channel in main.go.
go/observability-proxy/cmd/proxy/main.go Clean startup/shutdown sequence. WriteTimeout is set to 60s. The usage-reporter goroutine is properly synchronized with a done channel so the final metering flush completes before grpcClient.Close() is called.
charts/console/templates/observability-proxy/deployment.yaml Proxy deployment template. Uses console's service account instead of a dedicated, minimal one — violates least-privilege. Uses console.containerSecurityContext for the proxy container, which is a minor coupling.
charts/console/templates/networkpolicy.yaml Restricts Console's internal ports (4369, 50051) to same-namespace traffic via namespaceSelector. Service ports (3000, service.port, 9090) are intentionally left open. Protection depends on networkPolicy.consoleInternalPorts.enabled being true alongside observabilityProxy.enabled.
.github/workflows/observability-proxy-cd.yaml Multi-arch CD pipeline for three registries. upload-artifact and download-artifact are aligned on v7 (previously reported mismatch is resolved).
charts/console/templates/service.yaml Adds gRPC port 50051 unconditionally to the Console ClusterIP service (not gated on observabilityProxy.enabled). Combined with the independent networkPolicy.consoleInternalPorts.enabled flag this was flagged in a previous review thread.

Last reviewed commit: "fix(observability-pr..."

Comment thread charts/console/templates/observability-proxy/deployment.yaml
Comment thread go/observability-proxy/internal/proxy/handler.go
Comment thread go/observability-proxy/internal/metering/meter.go
Comment thread go/observability-proxy/cmd/proxy/args/args.go Outdated
floreks added 2 commits March 17, 2026 16:39
…terval

- Removed `queryRPS` and `queryBurst` configurations.
- Introduced `meterInterval` for improved observability proxy configuration.
- Added a return statement to prevent further processing upon a metering error.
- Removed unused `envIntOrDefault` utility function from `args.go`.
@floreks

floreks commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

@greptileai fixed issues. review again

Comment thread go/observability-proxy/internal/console/provider.go Outdated
Comment thread go/observability-proxy/internal/console/provider.go Outdated
Comment thread go/observability-proxy/internal/console/provider.go Outdated
Comment thread go/observability-proxy/internal/proxy/handler.go
… validation

- Integrated singleflight package to deduplicate concurrent config refreshes.
- Added caching logic improvements in `CachingProvider`.
- Introduced HTTP method validation for Prometheus query requests.
- Developed unit tests for concurrent config retrieval and method validation.
@floreks

floreks commented Mar 17, 2026

Copy link
Copy Markdown
Member Author

@greptileai all fixed, review

Comment thread go/observability-proxy/internal/console/client.go
Comment thread go/observability-proxy/internal/proxy/handler.go
Comment thread go/observability-proxy/cmd/proxy/main.go
Comment thread .github/workflows/observability-proxy-cd.yaml
floreks added 2 commits March 18, 2026 11:30
- Introduced a NetworkPolicy YAML template to secure console internal ports.
- Added gRPC port configuration to deployment and service templates.
- Updated `values.yaml` to include networkPolicy settings.
…rkflows

- Added test for Prometheus request byte counting when upstream is unavailable.
- Updated `Upload Artifact` actions to use version 7 in CI/CD workflows.
- Adjusted request byte counting logic in handler implementation.
- Set a write timeout of 60 seconds in server configuration.
@floreks

floreks commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

@greptileai

Comment thread go/observability-proxy/cmd/proxy/main.go Outdated
- Consolidated server startup logic and deferred shutdown procedures.
- Encapsulated gRPC client management with `closeGRPCClient` function.
- Implemented usage reporter with dedicated shutdown handling.
- Enhanced configuration warm-up with the `warmConfig` function.
- Structured HTTP server initialization and lifecycle management.
@floreks

floreks commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

@greptileai

Comment thread charts/console/templates/networkpolicy.yaml Outdated
Comment thread charts/console/values.yaml
- Added new TCP ingress port 3000 to NetworkPolicy.
- Changed namespace selector logic for network rules.
- Removed conditional block for grpc port in service template for consistent exposure.
@floreks

floreks commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

@greptileai

@socket-security

socket-security Bot commented Mar 18, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedk8s.io/​klog/​v2@​v2.140.099100100100100
Addedgolang.org/​x/​sync@​v0.18.099100100100100

View full report

floreks added 2 commits March 18, 2026 12:33
- Added `helm.sh/chart` and `app.kubernetes.io/instance` labels to HPA, service, and deployment templates.
- Adjusted matchLabels to align with new naming conventions for observability proxy.
- Incorporated pod annotations and labels from values.
…yment

- Updated the `app.kubernetes.io/name` label in the service template to accurately reflect the observability-proxy configuration.
@floreks
floreks marked this pull request as ready for review March 18, 2026 11:53
@floreks
floreks merged commit 75723f0 into master Mar 19, 2026
20 checks passed
@floreks
floreks deleted the sebastian/prod-4541-add-observability-proxy branch March 19, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants