Observability
Diverge exports comprehensive metrics for monitoring both the Controller and the Server.
Metrics
Section titled “Metrics”Server Metrics
Section titled “Server Metrics”The Diverge server collects the following metrics under the diverge_server namespace/subsystem:
diverge_server_rpc_requests_total: Total number of RPC requests by method and status.diverge_server_rpc_request_duration_seconds: RPC request duration in seconds.diverge_server_rpc_stream_duration_seconds: Duration of streaming RPCs in seconds.diverge_server_rpc_active_streams: Number of active streaming RPCs.diverge_server_auth_attempts_total: Authentication attempts by provider and result.diverge_server_broadcaster_subscribers: Number of active broadcaster subscribers.diverge_server_broadcaster_events_total: Total number of broadcaster events.diverge_server_broadcaster_drops_total: Total number of broadcaster drops.
Controller Metrics
Section titled “Controller Metrics”Diverge uses standard controller-runtime metrics for tracking reconcile loops and Kubernetes API interactions, plus custom metrics exported at :8080/metrics:
diverge_environment_estimated_hourly_cost_usd(labels:environment,namespace): Estimated hourly compute and database cost in USD for each active preview environment. Automatically drops to0when an environment scales to zero (divergedev.com/hibernated: "true") or is deleted.diverge_environment_ttl_remaining_seconds(labels:environment,namespace): Seconds remaining until TTL expiry. Exports negative values when an environment is stuck pastExpiresAtin non-terminating phases so theDivergeEnvironmentStuckalert fires accurately.diverge_controller_async_provisions_total(labels:protocol,result): Total async route provisions.diverge_controller_async_provision_duration_seconds(labels:protocol): Async route provisioning duration.diverge_controller_async_teardowns_total(labels:protocol,result): Total async route teardowns.diverge_controller_async_active_routes(labels:protocol): Currently active async routes.
Cost Estimation, Idle Hibernation, Namespace Quotas, & Baseline Drift
Section titled “Cost Estimation, Idle Hibernation, Namespace Quotas, & Baseline Drift”The controller continuously estimates the hourly cloud cost of each Environment (diverge_environment_estimated_hourly_cost_usd) using actual spec.deploy.resources.cpuRequest ($0.04/vCPU-hr) and memoryRequest ($0.004/GiB-hr) when specified (falling back to 0.25 vCPU + 0.5 GiB = $0.012/hr per default pod replica) plus isolated database overhead ($0.10/hr for cnpg/snapshot/fresh, $0.01/hr for schema).
- Idle Hibernation (
divergedev.com/hibernate-after): Annotating anEnvironmentwithdivergedev.com/hibernate-after: "30m"scales managed previewDeployments andStatefulSets down to0replicas, marks the environmentdivergedev.com/hibernated: "true", emits aHibernatedKubernetes Event, and zeroes active compute cost once no traffic has been observed sincedivergedev.com/last-traffic-at(orstatus.createdAt). - Namespace Quotas & FinOps LRU Auto-Hibernation: Platform teams can annotate any Kubernetes
Namespaceto enforce hard FinOps budgets and cluster capacity guardrails:divergedev.com/max-active-environments: Maximum concurrent non-hibernated previewEnvironments in the namespace.divergedev.com/max-cnpg-clusters: Maximum concurrent dedicated CloudNativePG (cnpg/fresh/snapshot) database clusters.divergedev.com/max-hourly-cost-usd: Maximum aggregate hourly FinOps burn rate across activeEnvironments in the namespace (e.g.,"2.50").divergedev.com/quota-exceed-policy:"hibernate-oldest"(default — automatically scales the least-recently-used activeEnvironments to zero replicas to make room for incoming PRs) or"reject"(marks the environmentFailedwithQuotaReady=False/Reason: QuotaExceeded).
- Baseline Drift Detection & Auto-Refresh (
divergedev.com/drift-policy): The controller computes a deterministic SHA-256 fingerprint (divergedev.com/baseline-fingerprint) over baselineDeploymentpod specs (Containers,InitContainers,env,envFrom) and referencedConfigMaps/Secrets (including projected volumeConfigMap/Secretsources), watching baselineDeploymentandConfigMapupdates in real time:divergedev.com/drift-policy: "warn"(default): Sets conditionBaselineDriftDetected=True(Reason: BaselineUpdated), emits aBaselineDriftDetectedWarning event, and surfaces⚠️ driftindiverge topfor active environments (💤 hibernatedtakes display precedence while scaled to zero).divergedev.com/drift-policy: "sync": Automatically re-runsDeployer.Deploy, injects the updateddivergedev.com/baseline-fingerprintinto preview pod templates to trigger a rolling restart, and emits aBaselineSyncedNormal event.divergedev.com/drift-policy: "ignore": Disables baseline drift checks for the environment.
- End-to-End W3C Trace Context (
divergedev.com/traceparent): GitHub and GitLab webhook handlers automatically extract incoming W3CtraceparentHTTP headers (or mint a fresh00-<trace-id>-<span-id>-01trace context when absent) and attachdivergedev.com/traceparentto created or updatedPreviewGroup,Environment, andAgentTaskCRs.PreviewGroupReconcilercopies it to childEnvironments,EnvironmentReconcilerlinks its OpenTelemetry reconcile span (environment.name,environment.namespace) to the caller’s trace, and database migration and hookJobcontainers receive it asTRACEPARENT. - Web Dashboard FinOps Visibility: The Diverge Web Dashboard displays real-time fleet hourly and projected monthly spend, hibernation status, per-environment cost badges, and 1-click
Hibernate/Wakecontrols alongside Magic Link copy buttons (?_diverge_env=).
Health Endpoints
Section titled “Health Endpoints”:9090/healthz: Liveness probe:8080/healthz: Controller status:8081/readyz: Readiness probe
Audit Logging
Section titled “Audit Logging”The Diverge server supports structured JSON audit logging for security and compliance. It logs details about authentication, authorization, and mutating API actions, including the user, action, and target resource.
ServiceMonitor Setup
Section titled “ServiceMonitor Setup”Diverge can be configured to automatically create ServiceMonitor objects by enabling them in the Helm values (.Values.metrics.serviceMonitor.* for the controller, and .Values.server.metrics.serviceMonitor.* for the server). This allows Prometheus Operator to automatically discover and scrape the metrics endpoints:
metrics: serviceMonitor: enabled: true
server: metrics: serviceMonitor: enabled: trueGrafana Dashboards
Section titled “Grafana Dashboards”Import the reference Grafana dashboards provided in the deploy/grafana/ directory of the Diverge repository to visualize Diverge server and controller metrics out of the box.
Alerting Rules
Section titled “Alerting Rules”Deploy the pre-configured Prometheus alerting rules provided in the deploy/prometheus/ directory of the Diverge repository to monitor for high RPC error rates, anomalous stream durations, or failing deployments.
