CubeProxy Request Metrics
CubeProxy exposes Prometheus-formatted request metrics for selected sandbox data-plane routes. These metrics help operators observe request traffic, in-flight requests, success and failure rates, and request latency while diagnosing routing or backend problems.
The metrics endpoint is served by a dedicated CubeProxy listener:
http://127.0.0.1:18082/metricsCubeProxy stores the metrics in an in-memory Nginx shared dictionary. A CubeProxy restart resets the counters, gauges, and histogram samples.
Enabling and disabling metrics
Request metrics are opt-in and disabled by default. To turn the feature on, set the CUBE_PROXY_METRICS_ENABLE environment variable to a truthy value (1, on, true, or yes):
CUBE_PROXY_METRICS_ENABLE=1Any other value, an empty value, or leaving the variable unset keeps metrics disabled. When disabled, CubeProxy records no request samples, the data-plane request phases skip metrics collection entirely, and no metrics listener is created — nothing binds any port — so the CUBE_PROXY_METRICS_LISTEN value is ignored in that case.
Deployment
Each deployment path exposes the toggle as a configuration knob (all default to off):
- one-click (docker compose): set
CUBE_PROXY_METRICS_ENABLE=1(and optionallyCUBE_PROXY_METRICS_LISTEN) in your.envbefore running the installer. - Helm chart: set
cubeProxy.metrics.enabled=true(and optionallycubeProxy.metrics.listen) in your values. - Terraform (TKE): set
cube_proxy_metrics_enabled = true(and optionallycube_proxy_metrics_listen) in your tfvars.
Metrics listener
The metrics listener is configured with the CUBE_PROXY_METRICS_LISTEN environment variable. Its default value is:
127.0.0.1:18082For Prometheus to scrape CubeProxy from another host, configure the listener with an address reachable from the Prometheus network. For example:
CUBE_PROXY_METRICS_LISTEN=0.0.0.0:18082The metrics listener exposes only the exact GET /metrics endpoint. Other paths return HTTP 404. The endpoint does not use CubeProxy's normal data-plane routes or admin server.
Network access
The metrics listener does not provide built-in authentication or TLS. Do not expose it to an untrusted network. Bind it to a trusted management address and restrict access with firewall or security-group rules.
Prometheus scrape configuration
The endpoint can be scraped with a manual Prometheus job:
scrape_configs:
- job_name: cubesandbox-cube-proxy
metrics_path: /metrics
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets:
- <cube-proxy-host>:18082Replace the target with the internal CubeProxy address that is reachable from Prometheus. If CubeProxy keeps the default listener 127.0.0.1:18082, Prometheus must run on the same host or use a local scrape agent.
Metric families
cube_proxy_request_total
A Counter containing the number of completed tracked requests.
Labels:
route— the normalized CubeProxy route.method—GETorPOST.result—successorfail.
A response with an HTTP status from 200 through 399 is recorded as success. Other status codes are recorded as fail.
result reflects the outcome as seen by CubeProxy, based on the HTTP status only. It does not reflect whether a call eventually succeeded inside the sandbox:
process.Process/StartandConnectare streaming calls. CubeProxy receives HTTP200as soon as the stream opens, so an error the sandbox reports later inside the stream is still recorded assuccess.- A user command that exits with a non-zero code is recorded as
success, because the call itself completed normally.
cube_proxy_inflight_requests
A Gauge containing the number of currently tracked requests that have started but have not yet been completed.
Labels:
route— the normalized CubeProxy route.
cube_proxy_upstream_response_seconds
A Histogram of how long the sandbox takes to start responding, in seconds: the time from CubeProxy forwarding a request to the sandbox until it receives the sandbox's response headers. Prometheus exposes the usual histogram samples:
cube_proxy_upstream_response_seconds_bucket{...}
cube_proxy_upstream_response_seconds_sum{...}
cube_proxy_upstream_response_seconds_count{...}The histogram measures service latency rather than total request time, so it is not affected by how long a user's command runs or how large a file is:
- For
process.Process/StartandConnect, it covers routing and starting or attaching to the process, not the command's runtime. - For file downloads, it covers the time until the sandbox starts sending the file, not the transfer itself.
- For file uploads, CubeProxy receives the whole request body before forwarding it, so the client's upload time is excluded. The time to send the body to the sandbox and for the sandbox to write it is included.
Requests that never reach a sandbox, such as errors CubeProxy returns itself, are counted in cube_proxy_request_total but are not recorded in this histogram.
The histogram uses the route, method, and result labels. The current buckets range from 0.001 seconds through 8.192 seconds, plus +Inf.
Current collection scope
The current implementation records only these normalized routes:
| Route | URI forms | Typical use |
|---|---|---|
sandbox_exec | /process.Process/* and /sandbox/<sandbox-id>/<container-port>/process.Process/* | Sandbox process execution and connection requests. |
sandbox_files | /files and /sandbox/<sandbox-id>/<container-port>/files | Sandbox file requests. |
Other URIs are not included in these metrics. The route label is intentionally normalized so sandbox IDs and container ports do not create a separate time series for every sandbox.
Request lifecycle
CubeProxy starts tracking a request during its rewrite phase. It increments the route's in-flight gauge and stores the normalized route in the request variables.
At request completion, CubeProxy reads the method, the final status, and the time until the sandbox started responding, then updates the counter and histogram and decrements the in-flight gauge.
The following applies only to the tracked sandbox_exec and sandbox_files routes.
Counted requests: every request whose target sandbox CubeProxy can identify is counted. This includes errors CubeProxy returns directly because the sandbox does not exist, is forbidden, has been deleted, or is temporarily unavailable (404, 403, 410, 503), and the 503 returned when no backend is available. Each request is counted once.
Requests that are not counted: if the target sandbox cannot be identified from the request (neither the Host header nor the E2b-Sandbox-* headers carry routing attributes, or the /sandbox/<sandbox-id>/<container-port> path is malformed), CubeProxy returns HTTP 400 directly. These client errors are not counted.
Verify the endpoint
From a host that can reach the listener, query the endpoint:
curl -fsS http://127.0.0.1:18082/metricsA newly started CubeProxy may expose only HELP and TYPE metadata or no request samples. Complete a tracked sandbox execution or file request before checking the corresponding counter and histogram samples.
PromQL examples
Tracked request rate
sum by (route, method, result) (
rate(cube_proxy_request_total[5m])
)Failed request rate
sum by (route, method) (
rate(cube_proxy_request_total{result="fail"}[5m])
)Current in-flight requests
sum by (route) (
cube_proxy_inflight_requests
)P95 sandbox response latency
histogram_quantile(
0.95,
sum by (le, route, method) (
rate(cube_proxy_upstream_response_seconds_bucket[5m])
)
)Troubleshooting
| Symptom | What to check |
|---|---|
curl cannot connect | Confirm CubeProxy is running, check CUBE_PROXY_METRICS_LISTEN, and verify that the listener address and firewall rules allow the request. |
| Prometheus cannot reach the endpoint | The default listener is loopback-only. Set CUBE_PROXY_METRICS_LISTEN to an internal address reachable from Prometheus and restart CubeProxy. |
| HTTP 404 from the metrics listener | Use the exact path /metrics. Other paths on the dedicated metrics listener intentionally return 404. |
| HTTP 200 but no request samples | Complete a tracked sandbox_exec or sandbox_files request and scrape again. Metadata may be present before the first sample. |
| Expected route is missing | Only the normalized sandbox_exec and sandbox_files routes are currently tracked. Other CubeProxy routes are outside the current collection scope. |
| Counters reset after restart | Metrics are stored in memory. A CubeProxy restart creates a new shared dictionary, so Prometheus should treat the values as normal counter and gauge resets. |
| Prometheus reports authentication errors | The metrics listener has no built-in authentication. Check the surrounding firewall, security group, proxy, or network policy configuration. |