Skip to content
Software capabilities
CockroachDB

Inspect active CockroachDB SQL sessions

CockroachDB exposes current SQL sessions with SHOW CLUSTER SESSIONS and the DB Console Sessions page. The SQL statement is useful in scripts, while the console adds status filters and session details.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. CLI: cockroach sql --execute
  2. Interface: DB Console → Sessions
CLI

cockroach sql --execute

Run SHOW CLUSTER SESSIONS to list currently active sessions across all nodes, including transaction and statement details exposed by the result.

Read source: CockroachDB SHOW SESSIONS
Requirements
The cockroach CLI and a secure SQL connection to the cluster. VIEWACTIVITY or VIEWACTIVITYREDACTED is required to see other users’ sessions.
Limitations
The statement reports currently active sessions and does not provide a historical session archive. VIEWACTIVITYREDACTED hides constants in other users' running queries.

Example shell

cockroach sql --url "$DATABASE_URL" --execute "SHOW CLUSTER SESSIONS"
Interface

DB Console → Sessions

Open the Sessions page in DB Console to review active, idle, and closed sessions and drill into session details.

Read source: CockroachDB Sessions page
Requirements
A secure-cluster DB Console login with admin, VIEWACTIVITY, or VIEWACTIVITYREDACTED privilege to see all users' sessions. Other users see only their own sessions.
Limitations
The table excludes closed sessions by default. Closed-session details are retained only in a bounded in-memory cache controlled by capacity and time-to-live settings.