Skip to content

Metrics ​

Metrics

Kloud Workspace ships with a built-in Prometheus-compatible metrics exporter that exposes resource and session telemetry for your running workspace. The exporter is disabled by default.

Enabling Metrics ​

Set this variable to true when launching the container:

  • WS_METRICS_ENABLE: Enables the Prometheus metrics exporter.
sh
docker run \
  -p 9100:9100 \
  -e WS_METRICS_ENABLE=true \
  ghcr.io/kloudkit/workspace:v0.6.0

Once enabled, the exporter serves metrics at / on port 9100 (default). Publish that port, as above, so Prometheus can reach it from outside the container.

Scraping and Visualization ​

Point your Prometheus instance at the workspace metrics port:

yaml
scrape_configs:
  - job_name: workspace
    static_configs:
      - targets:
        - <workspace-host>:9100

💡 TIP

Prometheus and Grafana are not bundled with Kloud Workspace.

The workspace only exposes a /metrics-compatible endpoint; scraping, alerting and dashboards are managed by your own infrastructure.

Configuration ​

Two more environment variables set the exporter's port and its collectors:

  • WS_METRICS_PORT: Port on which the metrics endpoint listens.
  • WS_METRICS_COLLECTORS: Comma-separated list of metric collectors to enable.

To expose metrics on a custom port with only CPU and memory collectors:

sh
docker run \
  -p 9200:9200 \
  -e WS_METRICS_ENABLE=true \
  -e WS_METRICS_PORT=9200 \
  -e WS_METRICS_COLLECTORS="container.cpu,container.memory" \
  ghcr.io/kloudkit/workspace:v0.6.0

Collectors ​

Collectors are organized hierarchically. Enabling a parent collector (e.g. container) implicitly enables all its children.

CollectorDescription
workspaceAll workspace metrics
workspace.infoWorkspace build info
workspace.sessionSession timestamp and uptime
workspace.extensionsInstalled extensions count
containerAll container metrics
container.cpuCPU usage metrics
container.memoryMemory usage metrics
container.fsFilesystem usage metrics
container.fdFile descriptor metrics
container.pidsProcess metrics
pressureAll pressure metrics (cgroup v2)
pressure.cpuCPU pressure metrics
pressure.memoryMemory pressure metrics
pressure.ioIO pressure metrics
networkNetwork metrics
socketsSocket metrics
ioIO metrics
gpuGPU metrics (requires nvidia-smi)

When unset or *, all collectors are enabled (gpu only when hardware is available).

Exposed Metrics ​

Workspace ​

MetricTypeDescription
workspace_infogaugeBuild info (labels: version, vscode_version)
workspace_session_initialized_timestamp_secondsgaugeUnix timestamp when initialized
workspace_session_uptime_secondsgaugeSeconds since initialization
workspace_extensions_installed_totalgaugeVS Code extensions installed

Container CPU ​

MetricTypeDescription
workspace_container_cpu_usage_seconds_totalcounterTotal CPU time consumed
workspace_container_cpu_user_seconds_totalcounterCPU time in user mode
workspace_container_cpu_system_seconds_totalcounterCPU time in system mode
workspace_container_cpu_periods_totalcounterTotal CPU scheduling periods
workspace_container_cpu_throttled_periods_totalcounterThrottled CPU periods
workspace_container_cpu_throttled_seconds_totalcounterTotal time throttled

Container Memory ​

MetricTypeDescription
workspace_container_memory_usage_bytesgaugeCurrent memory usage
workspace_container_memory_limit_bytesgaugeMemory limit
workspace_container_memory_rss_bytesgaugeAnonymous memory (cgroup v2)
workspace_container_memory_cache_bytesgaugePage cache memory
workspace_container_memory_swap_bytesgaugeSwap usage
workspace_container_memory_swap_limit_bytesgaugeSwap limit
workspace_container_memory_anon_bytesgaugeAnonymous memory
workspace_container_memory_kernel_bytesgaugeKernel memory
workspace_container_memory_slab_bytesgaugeSlab allocator memory
workspace_container_memory_oom_totalcounterOOM events
workspace_container_memory_oom_kill_totalcounterOOM kill events
workspace_container_memory_max_totalcounterTimes memory limit was hit

Container Filesystem ​

MetricTypeDescription
workspace_container_fs_usage_bytesgaugeFilesystem usage on WS_SERVER_ROOT
workspace_container_fs_limit_bytesgaugeFilesystem capacity on WS_SERVER_ROOT

Container File Descriptors ​

MetricTypeDescription
workspace_container_file_descriptors_opengaugeOpen file descriptors across all processes
workspace_container_file_descriptors_limitgaugeOpen-file limit of a single process

Container Processes ​

MetricTypeDescription
workspace_container_pids_currentgaugeCurrent number of processes
workspace_container_pids_limitgaugeProcess limit

CPU Pressure ​

MetricTypeDescription
workspace_pressure_cpu_waiting_seconds_totalcounterTotal time tasks waited for CPU
workspace_pressure_cpu_stalled_seconds_totalcounterTotal time all tasks stalled on CPU

Memory Pressure ​

MetricTypeDescription
workspace_pressure_memory_waiting_seconds_totalcounterTotal time tasks waited for memory
workspace_pressure_memory_stalled_seconds_totalcounterTotal time all tasks stalled on memory

IO Pressure ​

MetricTypeDescription
workspace_pressure_io_waiting_seconds_totalcounterTotal time tasks waited for I/O
workspace_pressure_io_stalled_seconds_totalcounterTotal time all tasks stalled on I/O

💡 TIP

Pressure metrics require cgroup v2 and are sourced from the PSI (Pressure Stall Information) subsystem.

Network ​

MetricTypeDescription
workspace_network_receive_bytes_totalcounterTotal bytes received
workspace_network_transmit_bytes_totalcounterTotal bytes transmitted
workspace_network_receive_packets_totalcounterTotal packets received
workspace_network_transmit_packets_totalcounterTotal packets transmitted
workspace_network_receive_errors_totalcounterTotal receive errors
workspace_network_transmit_errors_totalcounterTotal transmit errors

Totals cover every network interface in the container, loopback included.

Sockets ​

MetricTypeDescription
workspace_sockets_tcp_establishedgaugeEstablished TCP connections
workspace_sockets_tcp_listengaugeListening TCP sockets
workspace_sockets_udpgaugeUDP sockets

IO ​

MetricTypeDescription
workspace_io_read_bytes_totalcounterTotal bytes read from disk
workspace_io_write_bytes_totalcounterTotal bytes written to disk
workspace_io_read_ops_totalcounterTotal disk read operations
workspace_io_write_ops_totalcounterTotal disk write operations

GPU ​

MetricTypeDescription
workspace_gpu_utilization_ratiogaugeGPU utilization (0 to 1)
workspace_gpu_memory_used_bytesgaugeGPU memory used
workspace_gpu_memory_total_bytesgaugeGPU memory total
workspace_gpu_temperature_celsiusgaugeGPU temperature
workspace_gpu_power_wattsgaugeGPU power consumption

💡 TIP

GPU metrics require nvidia-smi to be available in the container, and cover only the first GPU it reports.

When the GPU collector is enabled but no GPU hardware is detected, these metrics are silently omitted. If gpu is the only collector, the exporter then has nothing to serve: it exits and keeps restarting.

Released under the MIT License