Features

Tusk observes and acts on live PostgreSQL activity. Here's the full picture.

Live views

Queries, transactions, sessions, locks, tables, indexes, rules, and violations — all with 2-second auto-refresh so you're always looking at current state.

CEL rules engine

Define policy rules in YAML using Common Expression Language. Rules evaluate continuously against live query, transaction, and lock state.

Violation tracking

A full audit log of rule violations with a timestamped event lifecycle: detected → action → cooldown → closed.

Auto remediation

Automatically take action on violations — terminate, cancel, or log — governed by per-rule cooldowns, dry-run mode, and a profile-level read-only guard.

Split-pane detail views

Query detail with formatted SQL, transaction detail with query history, and lock detail with blocker/blocked side-by-side.

Interactive Activity pane

Shows lock contention and rule violations per PID. Press Enter on a blocking PID to jump straight to its detail.

Column sorting & filtering

Toggle sort on any column with Shift+letter, and filter any view with / — the filter persists visually until cleared with Esc.

Keyboard-first navigation

Arrow keys cycle views, Tab cycles panes within detail views, and a : command prompt jumps anywhere.

Tusk transaction detail split-pane view
Transaction detail with query history in a split pane.

Views

Command Description
:queries Active queries with duration, wait events, blocking info
:transactions Active transactions sorted by age with lock counts
:sessions Connections grouped by user, app, state
:tables Table sizes, row counts, dead tuple %, vacuum stats
:locks Blocked/blocking lock pairs
:indexes Index scan counts and sizes
:rules Configured rules with violation counts
:violations Violation audit log with event timeline

Rules by example

Rules live in ~/.config/tusk/config.yaml under a profile. Each rule is a CEL when expression plus an action.

profiles:
  dev:
    url: "postgres://postgres:postgres@localhost:5432/mydb?sslmode=disable"
    rules:
      - name: kill-idle-in-txn
        resource: transaction
        when: "state == 'idle in transaction' && xact_duration > duration('5m')"
        action: terminate
        cooldown: 5m
        dry_run: true

      - name: long-queries
        resource: query
        when: "state == 'active' && duration > duration('30s')"
        action: cancel
        cooldown: 1m
        dry_run: true

Rule fields

Field Description
resource query, transaction, or lock
when CEL expression evaluated against the resource fields
action terminate, cancel, or log
cooldown Minimum interval between action firings per PID
dry_run Record violations but don't execute the action
readonly Profile-level: forces all rules to dry-run

For the CEL field reference and full configuration, see the generated documentation and the project README.

Key bindings

Key Action
← →Switch views
:Command prompt
/Filter
TabCycle panes in detail view
EnterDrill into detail / fire action
EscBack / clear filter
Shift+letterSort by column
cCancel query (in query detail)
tTerminate backend (in query/transaction detail)
qQuit