Aperture

Monitoring

Expose Prometheus metrics from the Aperture daemon, scrape them, and import the Grafana dashboard.

Aperture can serve Prometheus metrics on a dedicated listener. The listener is off by default and separate from the API listener, so Traefik never routes it and it is not reachable through the public URL.

Enable metrics

Set metrics_address to the address that serves GET /metrics:

metrics_address = "127.0.0.1:9464"

The environment variable APERTURE_METRICS_ADDRESS and the --metrics-address flag set the same value. metrics_per_session (default true) controls the per-session resource series. An empty value disables metrics, which is the default. The address must differ from listen_address and from the blue and green API addresses. Bind a non-loopback address only when Prometheus runs on another host, and restrict access to it with a firewall; the endpoint has no authentication.

With the NixOS module:

services.aperture.metrics = {
  enable = true;
  address = "127.0.0.1:9464";
};

The Docker Compose definition uses host networking, so setting APERTURE_METRICS_ADDRESS: 127.0.0.1:9464 in the service environment exposes the endpoint on the host's loopback interface.

Blue/green deployments

Both API colors read the same configuration, and only the active color binds metrics_address. During aperture-rollout the old color releases the address within a second of the switch, and the new color binds it once it is free. One scrape target therefore always reaches the daemon that owns the sessions. A scrape during that second can fail, and counters restart from zero with the new process, which Prometheus rate() and increase() handle as a counter reset. aperture_build_info reports the version and color of the daemon that serves the scrape.

Scrape configuration

scrape_configs:
  - job_name: aperture
    scrape_interval: 15s
    scrape_timeout: 10s
    static_configs:
      - targets: ["127.0.0.1:9464"]

Docker Compose with Prometheus

Add Prometheus next to the host-networked Aperture service:

# compose.monitoring.yaml
services:
  aperture:
    environment:
      APERTURE_METRICS_ADDRESS: 127.0.0.1:9464
  prometheus:
    image: prom/prometheus
    network_mode: host
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --web.listen-address=127.0.0.1:9090
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus-data:/prometheus

volumes:
  prometheus-data:

Start it with docker compose -f packaging/docker/compose.yaml -f compose.monitoring.yaml up -d, using the scrape configuration above as prometheus.yml.

Grafana dashboard

Import packaging/grafana/aperture-dashboard.json in Grafana under Dashboards → New → Import, then pick the Prometheus data source in the Data source variable. The dashboard groups panels into rows: overview, sessions, storage, garbage collection, live sessions and proxy, per-session resources, authentication, and Go runtime. The Job and Instance variables filter every panel, and the Session variable picks the sessions the per-session detail panels show.

Metrics

All Aperture metrics use the aperture_ prefix. Apart from the optional per-session resources, no metric carries session IDs, tokens, users, tenants, URLs, or paths as labels. HTTP routes use gin route templates such as /api/sessions/:sessionId; requests no route matched, including the web UI's files, share the route label static.

API

MetricTypeLabels
aperture_http_requests_totalcounterroute, method, status_class
aperture_http_request_duration_secondshistogramroute, method
aperture_http_requests_in_flightgauge
aperture_api_errors_totalcountercode (the API error code)
aperture_auth_logins_totalcountermethod
aperture_auth_failures_totalcountermethod, reason (API error code)

Authentication methods are password, password_mfa, passkey, oidc, api_token, web_session, and session_token (session, editor, and viewer capability tokens checked by Traefik forward auth).

Sessions and snapshots

MetricTypeLabels
aperture_sessionsgaugestatus
aperture_session_events_totalcounterevent: created, started, suspended, woken, reopened, deleted, expired, failed
aperture_session_start_duration_secondshistogramkind: create, reopen, wake
aperture_snapshotsgaugestate: active, deleted (deleted but not yet collected)
aperture_snapshot_promotions_totalcounterresult: succeeded, rejected (answered with a 4xx, such as a name conflict), failed
aperture_snapshot_promotion_duration_secondshistogram

aperture_sessions and aperture_snapshots are read from the database on every scrape. Start duration runs from mounting the overlay until the browser answers CDP.

Storage and garbage collection

MetricTypeLabels
aperture_storage_size_bytesgaugeroot: store, cold, database
aperture_storage_available_bytesgaugeroot
aperture_database_size_bytesgauge
aperture_state_scrape_errors_totalcountersource
aperture_gc_runs_totalcounterresult
aperture_gc_run_duration_secondshistogram
aperture_gc_removed_totalcounterkind: session, artifacts, snapshot
aperture_gc_staging_sweep_errors_totalcounter

Storage sizes come from statfs on the filesystem holding each root, so roots on one filesystem report the same values. The database size includes the write-ahead log.

Live sessions

These metrics aggregate every running session. On each scrape the daemon asks the wrapper of each running session for its counters over loopback, with a one-second timeout per wrapper, at most 16 requests at once, and a five-second limit for the whole poll. Scrapes less than five seconds apart reuse the previous poll.

MetricTypeLabels
aperture_live_session_clientsgaugerole, transport: websocket, webrtc, none (reconnecting)
aperture_media_viewersgaugerole
aperture_cdp_connectionsgauge
aperture_recordings_activegauge
aperture_recordings_started_totalcounter
aperture_recording_failures_totalcounterreason
aperture_session_uploads_totalcounter
aperture_session_upload_bytes_totalcounter
aperture_session_upload_failures_totalcounter
aperture_proxy_connections_activegauge
aperture_proxy_connections_totalcounter
aperture_proxy_connection_failures_totalcounter
aperture_local_tunnels_attachedgauge
aperture_session_wrappersgaugestate: reachable, unreachable
aperture_session_wrapper_poll_duration_secondsgauge
aperture_session_wrapper_poll_errors_totalcounter

Wrapper counters restart with each wrapper process and disappear with its session, so the daemon adds the growth it observes between polls to counters of its own. Activity between a wrapper's last poll and its exit is not counted, and a daemon that starts while sessions run counts their earlier activity once on its first poll. The upload counters also include uploads through POST /api/sessions/{sessionId}/files, which the daemon counts directly.

Per-session resources

These series carry a session_id label and exist only while the session's browser runs; they disappear when it stops, suspends, or is deleted. Their number grows with the number of concurrently running sessions, about seven series per session, and never includes labels, tags, or other values users choose.

MetricTypeNotes
aperture_session_cpu_seconds_totalcounter
aperture_session_memory_bytesgauge
aperture_session_memory_peak_bytesgaugecgroup source only
aperture_session_swap_bytesgauge
aperture_session_tasksgaugeprocesses and threads
aperture_session_io_read_bytes_totalcounterblock device reads
aperture_session_io_write_bytes_totalcounterblock device writes
aperture_session_resource_sessionsgaugesource: sessions read per source
aperture_session_resource_errors_totalcountersource: failed reads; never fail a scrape

Aperture reads them with the wrapper poll, from one of two sources:

  • cgroup: with the systemd supervisor (the NixOS module and the user units), each session is the unit browser-session@<id>.service with a cgroup of its own. Aperture finds it through the wrapper's /proc/<pid>/cgroup and reads cpu.stat, memory.current, memory.peak, memory.swap.current, pids.current, and io.stat. Memory includes the page cache the session caused.
  • process_tree: with the direct supervisor, as in the Docker image and nix run .#dev, every session shares the daemon's cgroup, and container cgroups are read-only. Aperture sums the wrapper and its descendants from /proc: CPU time including reaped children, the proportional set size (Pss in smaps_rollup, so shared pages count once), SwapPss, threads, and block I/O from /proc/<pid>/io. Hosts with only cgroup v1 use this source too. Processes that detach from the tree, such as Chromium's crash handler, are not counted.

A session whose source cannot be read, for example because its cgroup lacks the memory or pids controller, reports no series and counts an error for its source. The breakdown by component (Chromium, compositor, recorder) is not reported: CPU time of exited processes cannot be attributed reliably.

Per-session resources are on by default because their count is bounded by the running sessions and they are cheap to read. On hosts with many concurrent sessions, turn them off with metrics_per_session = false (APERTURE_METRICS_PER_SESSION=false, or services.aperture.metrics.perSession = false in the NixOS module).

Process

aperture_build_info has the labels version, commit, and color and the value 1. The standard Go runtime (go_*) and process (process_*) collectors describe the daemon itself.

Edit on GitHub

On this page