Skip to main content

Metrics

OpenKruise Agents exposes Prometheus metrics from two components:

  • Sandbox Controller — reconciles Sandbox, SandboxSet, and SandboxClaim resources, and emits per-instance state, lifecycle, and abnormality metrics.
  • Sandbox Manager — serves the E2B protocol and the Sandbox routing/proxy data plane, and emits per-request claim, lifecycle, routing, and quota metrics.

This page describes the metric endpoints, the Prometheus scrape configuration, and the full list of metrics that are registered on the master branch of openkruise/agents.

Endpoints​

ComponentHTTP pathDefault portNotes
Sandbox Manager/metrics8080 (--port)The /metrics handler is mounted on the main service mux. Use --metrics-port to expose a separate listener.
Sandbox Controller/metrics8443 (--metrics-bind-address)Standard controller-runtime metrics endpoint, served over HTTPS.

The Sandbox Controller endpoint is protected by controller-runtime's authentication / authorization filters, so the scraper must present a ServiceAccount token that is allowed to call /metrics.

Prometheus scrape configuration​

Self-managed Prometheus (prometheus.yml)​

scrape_configs:
- job_name: sandbox-manager
scrape_interval: 30s
scrape_timeout: 30s
metrics_path: /metrics
scheme: http
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- sandbox-system # adjust to the namespace where Sandbox Manager is deployed
relabel_configs:
- source_labels: [__meta_kubernetes_endpoint_port_name]
regex: manager
action: keep

- job_name: sandbox-controller
scrape_interval: 30s
scrape_timeout: 30s
metrics_path: /metrics
scheme: https
authorization:
credentials_file: /var/run/secrets/kubernetes.io/serviceaccount/token
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
kubernetes_sd_configs:
- role: endpoints
namespaces:
names:
- sandbox-system
relabel_configs:
- source_labels: [__meta_kubernetes_endpoint_port_name]
regex: https
action: keep

Prometheus Operator (ServiceMonitor)​

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: sandbox-manager
namespace: sandbox-system
labels:
release: prometheus # must match your Prometheus Operator's serviceMonitorSelector
spec:
namespaceSelector:
matchNames:
- sandbox-system
selector:
matchLabels:
app.kubernetes.io/name: sandbox-manager
endpoints:
- port: manager # the Service port that targets container port 8080
path: /metrics
interval: 30s
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: sandbox-controller
namespace: sandbox-system
labels:
release: prometheus
spec:
namespaceSelector:
matchNames:
- sandbox-system
selector:
matchLabels:
app.kubernetes.io/name: sandbox-controller
control-plane: controller-manager
endpoints:
- port: https
path: /metrics
scheme: https
interval: 30s
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tlsConfig:
insecureSkipVerify: true

Metrics reference​

All metric names below are exactly as registered in the source — no namespace or subsystem prefix is applied. Standard controller-runtime, workqueue_*, rest_client_*, go_*, and process_* metrics are also exposed by both components and are omitted from the tables for brevity.

Sandbox Controller​

Source: pkg/controller/sandbox/metrics.go, pkg/controller/sandboxset/metrics.go, pkg/controller/sandboxclaim/metrics.go, pkg/controller/sandboxclaim/core/metrics.go.

Sandbox instance state​

State gauges are emitted only while the Sandbox is in the corresponding state.

MetricTypeLabelsDescription
sandbox_infoGaugenamespace, name, plus user-allowlisted labelsConstant 1 series carrying static metadata about the Sandbox.
sandbox_labelsGaugedynamic, gated by --metric-labels-allowlistConstant 1 series exposing selected Sandbox labels as Prometheus labels.
sandbox_createdGaugenamespace, nameUnix timestamp at which the Sandbox was created.
sandbox_deletion_timestampGaugenamespace, nameUnix timestamp of metadata.deletionTimestamp, if set.
sandbox_status_phaseGaugenamespace, name, phaseCurrent status.phase (Pending, Running, Paused, Resuming, Failed, Succeeded, Terminating). Value 1 for the active phase.
sandbox_status_readyGaugenamespace, name1 when the Sandbox is Ready, 0 otherwise.
sandbox_status_ready_timeGaugenamespace, nameUnix timestamp of the last transition to Ready.
sandbox_status_inplace_updatingGaugenamespace, name1 while the InplaceUpdate condition is False (i.e. an in-place update is in progress).
sandbox_status_inplace_updating_timeGaugenamespace, nameUnix timestamp at which InplaceUpdate last became False.
sandbox_status_unpausedGaugenamespace, name1 while the SandboxPaused condition is False.
sandbox_status_unpaused_timeGaugenamespace, nameUnix timestamp at which SandboxPaused last became False.
sandbox_status_unresumedGaugenamespace, name1 while the SandboxResumed condition is False.
sandbox_status_unresumed_timeGaugenamespace, nameUnix timestamp at which SandboxResumed last became False.
sandbox_status_abnormalGaugenamespace, name, type1 when an abnormal condition of the given type is observed.
sandbox_status_abnormal_timeGaugenamespace, name, typeUnix timestamp at which the abnormal condition was last observed.
sandbox_runtime_container_abnormalGaugenamespace, name, container1 when a runtime container is in an abnormal state.
sandbox_runtime_container_abnormal_timeGaugenamespace, name, containerUnix timestamp at which the container abnormal state was last observed.

Sandbox lifecycle counters and histograms​

MetricTypeLabelsDescription
sandbox_creation_totalCounternamespace, resultSandbox creations attempted, by result.
sandbox_creation_duration_secondsHistogramnamespaceTime from Sandbox creation to Ready.
sandbox_pause_totalCounternamespace, resultPause operations performed by the controller.
sandbox_pause_duration_secondsHistogramnamespaceTime spent in a controller-driven pause operation.
sandbox_resume_totalCounternamespace, resultResume operations performed by the controller.
sandbox_resume_duration_secondsHistogramnamespaceTime spent in a controller-driven resume operation.
sandbox_inplace_update_duration_secondsHistogramnamespaceTime spent in an in-place update.
sandbox_deletion_duration_secondsHistogramnamespaceTime from deletionTimestamp set to final removal.

SandboxSet​

MetricTypeLabelsDescription
sandboxset_createdGaugenamespace, nameUnix timestamp at which the SandboxSet was created.
sandboxset_replicasGaugenamespace, nameCurrent status.replicas.
sandboxset_available_replicasGaugenamespace, nameCurrent status.availableReplicas.
sandboxset_desired_replicasGaugenamespace, nameCurrent spec.replicas.
sandboxset_updated_replicasGaugenamespace, nameCurrent status.updatedReplicas.
sandboxset_updated_available_replicasGaugenamespace, nameCurrent status.updatedAvailableReplicas.
sandboxset_sandboxes_created_totalCounternamespace, nameSandboxes created for this SandboxSet.
sandboxset_sandboxes_claimed_totalCounternamespace, nameSandboxes from this SandboxSet that have been claimed.

SandboxClaim​

MetricTypeLabelsDescription
sandbox_claim_infoGaugenamespace, name, plus selectorsConstant 1 series carrying static metadata.
sandbox_claim_createdGaugenamespace, nameUnix timestamp at which the SandboxClaim was created.
sandbox_claim_status_phaseGaugenamespace, name, phaseCurrent phase of the SandboxClaim.
sandbox_claim_start_timeGaugenamespace, nameUnix timestamp at which claiming started.
sandbox_claim_completion_timeGaugenamespace, nameUnix timestamp at which claiming completed.
sandbox_claim_claimed_replicasGaugenamespace, nameCurrently claimed replicas.
sandbox_claim_desired_replicasGaugenamespace, nameDesired replicas from spec.
sandbox_claim_duration_secondsHistogramnamespaceEnd-to-end claim duration measured by the controller.
sandboxset_claims_totalCounternamespace, nameTotal claim events observed per SandboxSet.
sandboxclaim_expired_totalCounternamespaceSandboxClaims that expired before being satisfied.

Sandbox Manager​

Source: pkg/sandbox-manager/metrics.go, pkg/servers/e2b/metrics.go, pkg/proxy/metrics.go, pkg/sandbox-manager/quota/metrics.go, pkg/sandbox-manager/infra/sandboxcr/metrics.go.

Claim path​

MetricTypeLabelsDescription
sandbox_claim_totalCounternamespace, result, lock_typeClaim requests received by Sandbox Manager.
sandbox_claim_creation_responsesCounternamespace, resultSandbox creations triggered by a claim, by result.
sandbox_claim_duration_secondsHistogramnamespaceEnd-to-end claim latency observed by Sandbox Manager.
sandbox_claim_retriesHistogramnamespaceNumber of retries taken to satisfy a claim.

Lifecycle operations​

MetricTypeLabelsDescription
sandbox_clone_totalCounternamespace, resultSandbox clone requests received.
sandbox_clone_duration_secondsHistogramnamespaceLatency of clone operations.
sandbox_delete_responsesCounternamespace, resultDelete requests received.
sandbox_delete_duration_secondsHistogramnamespaceLatency of delete operations.
sandbox_pause_responsesCounternamespace, resultPause requests received by Sandbox Manager.
sandbox_pause_duration_secondsHistogramnamespaceLatency of pause operations as observed by Sandbox Manager.
sandbox_resume_responsesCounternamespace, resultResume requests received by Sandbox Manager.
sandbox_resume_duration_secondsHistogramnamespaceLatency of resume operations as observed by Sandbox Manager.
sandbox_snapshot_totalCounternamespace, resultSnapshot creation requests received via the E2B server.
sandbox_snapshot_duration_secondsHistogramnamespaceLatency of snapshot creation.

sandbox_pause_duration_seconds and sandbox_resume_duration_seconds are registered separately by Sandbox Manager and Sandbox Controller. They are different series, scraped from different jobs — keep the job label when comparing them.

Routing and proxy​

MetricTypeLabelsDescription
sandbox_routesGauge—Current size of the proxy routing table.
sandbox_peersGauge—Number of connected peer nodes.
sandbox_route_sync_totalCounternamespace, type, resultRoute synchronization operations performed.
sandbox_route_sync_duration_secondsHistogramnamespace, typeLatency of route synchronization operations.

Quota​

MetricTypeLabelsDescription
sandbox_manager_quota_acquire_totalCounternamespace, resultQuota acquisitions attempted.
sandbox_manager_quota_release_totalCounternamespace, resultQuota releases attempted.
sandbox_manager_quota_backend_errors_totalCounternamespace, error_typeErrors returned by the quota backend.
sandbox_manager_quota_breaker_state_totalCounternamespace, from, toState transitions of the quota circuit breaker.
sandbox_manager_quota_breaker_open_duration_secondsHistogramnamespaceTime the quota circuit breaker spent in the open state.
sandbox_manager_quota_antidrift_skipped_totalCounternamespace, reasonAnti-drift reconciliations skipped.
sandbox_manager_quota_antidrift_errors_totalCounternamespace, error_typeAnti-drift reconciliations that errored.
sandbox_manager_quota_antidrift_event_release_totalCounternamespace, resultAnti-drift event-driven quota releases.

Infra fallbacks​

MetricTypeLabelsDescription
sandbox_get_claimed_fallback_totalCounternamespace, reasonTimes the Sandbox Manager fell back when reading claimed Sandboxes.
sandboxcr_quota_source_event_drop_totalCounternamespace, reasonQuota-source events dropped while watching Sandbox CRs.

Suggested alerts and panels​

The following PromQL snippets are starting points; tune thresholds against your own traffic profile.

  • Pool starvation — sum(sandboxset_available_replicas) by (namespace, name) == 0 while sum(sandboxset_desired_replicas) by (namespace, name) > 0.
  • Claim slowness — histogram_quantile(0.95, sum(rate(sandbox_claim_duration_seconds_bucket[5m])) by (le, namespace)).
  • Claim failure rate — sum(rate(sandbox_claim_total{result!="success"}[5m])) by (namespace) / sum(rate(sandbox_claim_total[5m])) by (namespace).
  • Lifecycle regression — compare p95 of sandbox_pause_duration_seconds_bucket, sandbox_resume_duration_seconds_bucket, and sandbox_clone_duration_seconds_bucket week over week.
  • Routing instability — rate(sandbox_route_sync_total{result!="success"}[5m]) > 0 or sandbox_peers dropping below the expected replica count.
  • Quota backend pressure — rate(sandbox_manager_quota_backend_errors_total[5m]) sustained above zero, or sandbox_manager_quota_breaker_state_total{to="open"} increasing.
  • Controller health — standard controller_runtime_reconcile_errors_total, workqueue_unfinished_work_seconds, and rest_client_requests_total{code=~"5.."}.

Notes​