feat: add observability proxy - #3332
Conversation
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.
… associated tests`
…centralize health and readiness handlers
…-add-observability-proxy
…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.
…-add-observability-proxy
…-add-observability-proxy
… 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"`.
|
@greptileai review this PR. ES/Prom credentials are ignored intentionally. Clients are reponsible for sending credentials in requests to proxy. |
Greptile SummaryThis 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 Several issues flagged in earlier review rounds have been addressed in this revision: the thundering-herd on config-cache expiry is solved with Remaining observations:
Confidence Score: 4/5
|
| 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..."
…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`.
|
@greptileai fixed issues. review again |
… 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.
|
@greptileai all fixed, review |
- 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.
- 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.
- 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.
…proved concurrency handling`
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
- 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.
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
deployment.yaml,service.yaml, andhpa.yaml, enabling deployment, service exposure, and autoscaling for the proxy. [1] [2] [3]values.yamlto control proxy deployment, resource allocation, autoscaling, and connection settings.CI/CD Workflow Enhancements
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
ingress.yamlto route observability endpoints (/ext/v1/ingest,/ext/v1/query) to the Observability Proxy service when enabled.values.yaml. [1] [2]Console Service and Deployment Updates
Supporting Files
go.workand provided a.gitignoreand 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
Checklist
Plural Flow: console