PostgreSQL monitoring and investigation - sessions, queries, blocking, replication
736
PostgreSQL monitoring and investigation in one small image: what your databases are doing now (connections, queries by type, sessions, blocking, replication), how they got there (history, incidents with evidence), and opt-in, read-only data browsing and SQL.
Source, documentation, and issues: https://github.com/Huy-8bit/locklens
LockLens keeps its history in its own PostgreSQL database (the store), never in the databases it monitors.
# Generate the master key once and keep it (a password manager, a secret store).
export LOCKLENS_MASTER_KEY="$(openssl rand -base64 32)"
docker network create locklens
docker run -d --name locklens-store --network locklens \
-e POSTGRES_USER=locklens -e POSTGRES_PASSWORD=change-me -e POSTGRES_DB=locklens \
-v locklens-store:/var/lib/postgresql \
postgres:18-alpine
docker run -d --name locklens --network locklens \
-p 127.0.0.1:8080:8080 \
-e LOCKLENS_LISTEN=0.0.0.0:8080 \
-e LOCKLENS_STORE_DSN='postgres://locklens:change-me@locklens-store:5432/locklens?sslmode=disable' \
-e LOCKLENS_MASTER_KEY \
-e LOCKLENS_ADMIN_PASSWORD='choose-a-long-password' \
-e LOCKLENS_COOKIE_SECURE=false \
johnnynguyen882/locklens:latest
Open http://127.0.0.1:8080, sign in as admin, and add a PostgreSQL instance
under Settings → Add instance by pasting its connection string. A regular
role is used as is; for a superuser, LockLens offers to create its own
least-privilege roles and stores only those.
Keep the master key: it encrypts the stored connection strings, and a new key
makes them unreadable. LOCKLENS_COOKIE_SECURE=false is only for plain HTTP
on your own machine; behind HTTPS, leave it unset.
| Variable | Required | Description |
|---|---|---|
LOCKLENS_STORE_DSN | yes | PostgreSQL 14+ database for LockLens' own data |
LOCKLENS_MASTER_KEY | yes | 32 random bytes, base64 (openssl rand -base64 32) |
LOCKLENS_ADMIN_PASSWORD or LOCKLENS_ADMIN_PASSWORD_HASH | first start | Creates the environment administrator (password 12–72 bytes, or a bcrypt hash); add more users with roles in the UI |
LOCKLENS_LISTEN | in a container | Default 127.0.0.1:8080; use 0.0.0.0:8080 inside a container |
LOCKLENS_ADMIN_USER | no | Default admin |
LOCKLENS_RETENTION | no | History retention, default 168h |
LOCKLENS_BOOTSTRAP_TARGETS_FILE | no | JSON file of instances to register at startup |
LOCKLENS_LOG_FORMAT | no | text (default) or json |
Full list: configuration.
8080. Health: GET /healthz (liveness), GET /readyz (store
reachable). Prometheus metrics at /metrics.10001. Platforms: linux/amd64, linux/arm64.latest (main branch), X.Y.Z and X.Y (releases).locklens CLI commands (inspect, watch,
snapshot, doctor) and the locklens-lab scenario runner used by the
demo stack; the server never runs lab code.LockLens observes; it never kills sessions, cancels queries, changes settings, or runs DDL/DML on monitored databases. Table browsing and the SQL editor are off by default, never use an administrative role, and run in read-only transactions. Paste a superuser connection string once and LockLens creates least-privilege roles for itself (after you confirm) instead of storing it. Connection strings are encrypted and never shown, logged, or exported.
Content type
Image
Digest
sha256:3343d6087…
Size
12.9 MB
Last updated
9 days ago
docker pull johnnynguyen882/locklens