Devtools in production
The production monitor shows a running app’s requests, queries, errors, resources, health and jobs in the browser, without a shell on the server. It is off unless you turn it on. With no production configuration, nothing is mounted and nothing is captured, so it costs nothing. Development is unchanged: see Devtools.
How it is protected is in Devtools security. Read it before you turn the monitor on.
Install
Section titled “Install”In production the package must be installed, so it is a regular dependency (not a development one):
npm install @warlock.js/devtoolsRegister the connector, the migrations and the commands in warlock.config.ts:
import { defineConfig } from "@warlock.js/core";import { devtoolsConnector } from "@warlock.js/devtools";import { devtoolsMigrations, registerDevtoolsCommands } from "@warlock.js/devtools/production";
export default defineConfig({ connectors: [devtoolsConnector()], cli: { commands: [registerDevtoolsCommands()] }, database: { migrations: [...devtoolsMigrations] },});warlock dev skips its own automatic registration when a devtools connector is configured, so development works as
before.
Turn the monitor on in src/config/devtools.ts. It stays a plain object that reads the environment:
import { env } from "@warlock.js/core";
export default { panels: ["@warlock.js/grimoire/devtools"], production: { enabled: env("DEVTOOLS_ENABLED", false), trustedProxies: ["loopback"], },};DEVTOOLS_ENABLED is your own variable here; devtools reads only the production object. Run the migrations once per
database:
npx warlock migrateThe accounts, sessions, audit log, request samples and instance reports live in your app’s database through Cascade
(MongoDB or SQL). They use nine tables or collections: devtools_accounts, devtools_sessions, devtools_invites,
devtools_audit, devtools_state, devtools_samples, devtools_reports, devtools_shares (share links, see below) and devtools_ai_rollups (hourly AI totals, see AI reports). The audit time is stored in occurred_at, and
the detail of a request sample and each instance report are stored as JSON text. No cache driver is needed. The monitor needs encryption.key (64 hex characters) in
src/config/encryption.ts, because two-factor secrets are stored encrypted with it.
Environment variables
Section titled “Environment variables”| Variable | Required | Meaning |
|---|---|---|
DEVTOOLS_PATH | Yes | The dashboard path, for example /ops-7f3k2q9x. Starts with /, at least 8 characters, only letters, digits and - _ . ~ /. |
DEVTOOLS_ADMIN_EMAIL | While no admin exists | The first admin. |
DEVTOOLS_ADMIN_PASSWORD | One of these two while no admin exists | A first password. It works until it is changed at the first sign-in, which is forced. It must pass the password rules. |
DEVTOOLS_SETUP_TOKEN | One of these two while no admin exists | At least 32 characters (openssl rand -base64 32). The admin opens <origin><path>/#/setup/<token> and chooses a password. |
Set either the password or the setup token, not both. The path is never written in full to the app’s logs: the boot log
shows only its first characters, core’s persistent request log and its one-line request summary (http.log) skip it,
and a dashboard error is logged with the route relative to the path. Pick a path nobody can guess; it is one layer of
protection, not the only one.
First sign-in
Section titled “First sign-in”With DEVTOOLS_ADMIN_PASSWORD:
- Open
https://<your-app><path>/and sign in withDEVTOOLS_ADMIN_EMAILand the password. - The dashboard asks you to choose a new password. The environment password is never applied again.
- Scan the QR code with an authenticator app and enter the 6-digit code. Or add a passkey, if passkeys are available.
- Save the 10 recovery codes shown once. Each works one time.
With DEVTOOLS_SETUP_TOKEN, open the setup link instead, choose a password, then continue from step 3.
After the first admin exists, you can remove both variables from the environment.
Users and roles
Section titled “Users and roles”| Role | Can do |
|---|---|
viewer | Read every enabled tab. Manage their own account, password, second factors and sessions. |
admin | Everything a viewer can, plus: invite and remove users, change roles, reset a user’s second factors, read the audit log, run EXPLAIN, clear requests, disable the dashboard and use write actions of package panels. |
An admin invites a user from Admin, Users: enter the email and role, then copy the link and send it yourself. No mail is sent. The link:
- is valid for 24 hours and works once,
- is tied to the invited email,
- can be revoked from the same screen,
- keeps its token after the
#, so the token never appears in server logs.
The last admin cannot be removed or demoted, and nobody can remove or demote their own account.
Two-factor sign-in
Section titled “Two-factor sign-in”twoFactor: "admins" (the default) requires a second factor for admins and lets viewers add one. "everyone"
requires it for all accounts. "off" requires it for nobody: users can still add an authenticator app or a passkey
themselves, and an account that has a factor is always asked for it at sign-in. With "off", boot logs a warning,
because anyone with a password can then sign in.
Password rules are set with passwords: { minLength, rejectCommon }. minLength is the shortest password in characters
(8 or more, default 8); rejectCommon (default true) refuses passwords from the built-in list of common passwords.
A password is never accepted when it equals the account’s email or exceeds 72 bytes, so minLength cannot be above 72: a larger value stops the boot with DT007.
- Authenticator app: any TOTP app. A code cannot be used twice.
- Passkeys: install
@simplewebauthn/server(the same optional package@warlock.js/authuses). Without it the dashboard offers the authenticator app only. Setpasskeys.rpIdandoriginwhen the app is served on more than one host. - Recovery codes: 10 single-use codes. Regenerate them from the account page with a current code from the authenticator app, or with a passkey.
Adding or removing an authenticator app or a passkey from the account page asks for your current password, so a stolen session alone cannot change your second factors.
An admin can reset another user’s second factors. If the last admin loses theirs, see Recovery.
Disable and re-enable
Section titled “Disable and re-enable”An admin can close the dashboard from Admin, Settings, Disable. Every instance reads the switch within 5 seconds, and it survives restarts. While disabled, every dashboard URL answers a plain 404.
To open it again:
- run
npx warlock devtools:enable, or - deploy with a new
DEVTOOLS_PATH. A disable switch matches only the path it was set for. Use this after a leak.
Share links
Section titled “Share links”An admin can give someone a read-only link to one panel, for example the Grimoire product map, so people without an account can read it. Sharing is off until you turn it on:
export default { production: { enabled: true, share: { enabled: true, maxDays: 30 }, },};A panel can be shared only when it declares a shared view (share, see Registering a panel).
The Grimoire panel does.
Migration. Links are stored in the devtools_shares table. devtoolsMigrations creates it; run warlock migrate
before you turn sharing on. When share.enabled is true and the table is missing, the app refuses to boot with
DT008 naming devtools_shares. An app that does not share links needs no new table.
Create a link. Sign in as an admin and open Admin, Share links. Choose the panel, give the link a label and a
number of days (1 up to share.maxDays) and create it. The link looks like
https://app.example.com/ops-7f3k2q/#/share/<token>. It is shown once: copy it then. Only a SHA-256 of the token is
stored, so it cannot be shown again. The token sits after the #, so it never reaches an access log or a Referer
header, and the page removes it from the address bar as soon as it opens.
Manage links. The same page lists every link with its status (active, expired, revoked), expiry, last use and number
of uses. Revoke stops one link. Revoke all links stops every active link and asks you to type revoke all. A
revoke reaches every instance within 5 seconds.
What a link gives. Opening it sets a cookie (__Secure-warlock-devtools-share) that lasts as long as the link, at
most 12 hours, and that reaches one panel’s shared view and nothing else: the panel’s share.routes, share.assets
and, when set, its images. It cannot reach another panel, the signed-in routes, the admin pages or the account. The
cookie is HttpOnly, Secure, SameSite=Strict and limited to the dashboard path. What the shared view shows is up to
the panel; the Grimoire product map shows titles, summaries, stories, screenshots, release history and test health
counts, never file paths, code, test names or error messages.
When it does not work. A wrong, expired or revoked link, a missing cookie and a closed dashboard all answer the same
404 as any unknown URL of your app, and the page says “This link has expired or was revoked”. Each failed token is
written to the audit log as share.failed (with the reason, never the token) and counts toward the per-IP failure limit
(rateLimits.ip), so a client that guesses tokens is refused. The HTTPS, allowed-IP and disabled-dashboard rules apply
to links as they do to sign-in. Sharing is not available in development: the loopback dashboard cannot be shared.
Creating and revoking links are audited as share.created and share.revoked.
Recovery
Section titled “Recovery”If no admin can sign in, run on the server:
npx warlock devtools:reset-admin --email you@example.comIt creates or resets that account as an admin, prints a temporary password you must change at sign-in, removes its
second factors and recovery codes, unlocks it and signs out its sessions. Without --email it uses
DEVTOOLS_ADMIN_EMAIL. It talks to the database only and writes an audit entry from cli.
devtools:enable also clears a global sign-in lock and resets the failure counts.
Several instances
Section titled “Several instances”Many apps run as several processes (pm2 cluster workers, several machines). Everything shared lives in the database:
| Shared by every instance | Per instance |
|---|---|
| Accounts, sessions, invites, audit log, the disable switch | The live event stream (new requests and logs as they happen) |
| Stored request samples | The in-memory list of sampled requests |
| Resource history, query and route statistics, errors, health, jobs, merged from each instance’s report | The query text kept for EXPLAIN |
Each process writes one report row every 10 seconds (reportIntervalMs). The dashboard merges the reports. The
instance picker in the header selects All instances (the default) or one process. The live stream follows the
instance that served your connection.
What is captured
Section titled “What is captured”One random draw per request decides whether it is sampled (sampleRate, 0.1 by default).
- A sampled request is captured fully: phases, queries, cache counts and logs. It feeds the query, route and error
statistics, and is stored for
requestRetentionHours(24). - An unsampled request does no capture work. If it is slow (
slowRequestMs, 1000) or fails (5xx or thrown), it is kept as a summary without a timeline, and its error is recorded. - A query that is at least
slowQueryMs(200) outside a sampled request only updates the slowest example of its shape. - Work outside a request is sampled per query at
sampleRate.
MongoDB reports its queries only when command monitoring is on, which it is not in production by default. With
devtools.production.enabled set in src/config/devtools.ts, or production: { enabled: true } passed to
devtoolsConnector(), core turns queryEvents on for you in a process that serves HTTP; it adds a small cost to every
query. An explicit queryEvents: false on the data source wins, and then the boot log says that query events are off
and the Queries tab stays empty. PostgreSQL needs nothing.
Memory is bounded per process: 200 sampled requests, 200 queries per request, 500 query shapes, 300 routes and 100 error
groups. The oldest are dropped first. Each process writes at most maxStoredSamplesPerMinute (120) samples per minute.
What is removed
Section titled “What is removed”Nothing that leaves the process (the API, the database, the live stream) carries a value:
| Item | Kept | Removed |
|---|---|---|
| Request | Id, method, path (no query string), route pattern, status, timing, error message and stack | Headers, body, query string, params; quoted values, emails and { … } documents in the error |
| Query | Connection, driver, shape (SQL with placeholders), collection, command, timing, row count, error message | SQL literals, bindings, Mongo filter and pipeline values, caller file path |
| Log | Level, module, action, message, time | context; quoted values, emails and { … } documents in error messages |
| Phase | Name, start, duration | attrs |
| Cache | Hit, miss and write counts | Keys and tags |
| N+1 | Shape, count, message | Caller location |
Headers and bodies appear only through core’s request log, which applies its own allowlist and redaction. The dashboard’s own requests are never captured and never written to that log.
The path is kept as the app served it, because it is what you look for when a request fails. Keep secrets out of URL
paths (a reset link such as /reset/<token> is better as /reset?token=<token> or a form post); anyone who can sign in to
the dashboard can read the paths of sampled and failed requests for requestRetentionHours.
EXPLAIN
Section titled “EXPLAIN”Admins can explain a query shape from the Queries tab. Only the process that ran the query holds the example, so EXPLAIN asks that process; from another one it answers that the example is elsewhere, and you can try again.
- PostgreSQL:
EXPLAIN (FORMAT JSON)for oneSELECTorWITHstatement that writes nothing. Strings, quoted names, dollar-quoted bodies and comments are read the way PostgreSQL reads them, so a;or a keyword cannot hide in them. The plan runs in a read-only transaction that is always rolled back. - MongoDB:
explainwithqueryPlannerverbosity forfind,aggregateandcount. An aggregate with$outor$mergeis never explained.
A plan repeats the query’s values (MongoDB echoes the filter, PostgreSQL writes values into conditions), so the
dashboard shows ? in their place. The plan’s steps, indexes, costs and row counts stay.
These plans do not run the query. Plans that do (PostgreSQL EXPLAIN ANALYZE, MongoDB executionStats) run only with
explain: { executing: true }, and only for those read statements. They run the real query against your production
database, so turn them on only when you accept the load. In PostgreSQL the read-only transaction also stops a function
the query calls from writing. Every run is audited.
Tabs in production
Section titled “Tabs in production”| Tab | In production |
|---|---|
| Requests, Queries, Routes, Resources, Health, Errors, Logs, Jobs | On (Jobs shows each schedule’s recent runs and the queue counts) |
| AI Reports, Models, Errors | On when Panoptic is installed; see AI reports |
| Mail, AI Evaluate, API, Processes | Off unless panels sets the id to true |
| AI Runs, Agents | Development only: panels cannot turn them on |
| A package panel (such as Grimoire) | On when it declares production: true, or panels sets its id to true |
The API tab builds its OpenAPI document from the routes the process registered. Under warlock start there are no
source files to read, so response resources are named Resource1, Resource2, … instead of their class names.
panels: { mail: false } turns any tab off. In a package panel, GET routes need a signed-in user; every other method
needs an admin, the CSRF header, and is audited. The Grimoire tab is read-only in production. See
Registering a panel.
AI reports
Section titled “AI reports”With @warlock.js/ai and @warlock.js/ai-panoptic installed and observation on (ai.config({ panoptic: { observeAll: true } })),
the AI group of the sidebar shows three pages in production: Reports, Models and Errors. They show hourly
totals of agent runs, tokens, estimated cost, errors by category, latency, fallbacks and refusals. See
AI section for what each page shows.
- Migration. The totals live in the
devtools_ai_rollupstable, part ofdevtoolsMigrations. After upgrading, runwarlock migrateand restart. Until then the process logs one warning and the pages show “AI reports need their table” with the command; nothing else is affected, and the monitor still starts. - Default tabs.
ai-reports,ai-modelsandai-errorsare on by default, but only when Panoptic is installed and loads. Without it they are not listed. Setproduction.panelsto turn any of them on or off by id:panels: { "ai-reports": false }, orpanels: { "ai-reports": true }to keep a tab listed so it can explain what is missing. - Every process contributes. Each process that boots the devtools connector (workers, cluster members, queue worker processes running the app) adds its runs to the same table, so the pages add up all of them. A run from another process shows within a minute.
- Retention. Totals are kept 90 days by default (
devtools.ai.retentionDays, 1 to 400); every process prunes older hours.devtools.ai.reports: falseturns the writer off, and so does turning off all three report tabs withpanels. - What stays in development. Runs, Agents and Evaluate show prompts, tool data and single-run details,
and Evaluate spends a model call, so they stay in development. Setting
panels.aiorpanels.agentstotruein production is ignored: the tabs are not listed, their routes are not registered, and boot logs one warning (“The Runs and Agents tabs are development tabs …”). Production shows AI totals in Reports, Models and Errors instead. Evaluate never grades in production: its page explains where to run it, andPOST /api/ai/evaluatedoes not exist there. The totals hold names and numbers only: no prompts, completions, tool data or user ids. - Access. The three report pages need a signed-in user (viewer or above); a tab turned off answers the same empty 404 as an unknown path. Cost is always an estimate from model pricing; runs of unpriced models are counted separately.
export default { ai: { retentionDays: 90 }, production: { enabled: true, panels: { "ai-errors": false } },};Behind a proxy
Section titled “Behind a proxy”By default the socket address is the client and the request’s own protocol and host are used. A forwarded header is
read only when the socket peer is listed in trustedProxies. Without it, requireHttps fails behind a TLS-terminating
proxy and the dashboard answers 404. Example for nginx on the same machine:
location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_buffering off;}Set trustedProxies: ["loopback"] for this. nginx passes on any header the client sent unless the configuration sets
it, so set every forwarded header the dashboard reads (X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host), and
set origin to your public origin so the CSRF check and passkeys never depend on a header. Entries can be IP addresses, CIDR ranges, "loopback" or "private".
proxy_buffering off lets the live view reach the browser at once. The dashboard also sends X-Accel-Buffering: no,
which nginx honours when buffering is on.
Performance
Section titled “Performance”With the monitor off, nothing is attached. With it on, a request that is not sampled does one random draw and a timing check.
Measured on 5.56.0 (Intel Xeon Gold 6312U, Node 22), driving the capture hooks for 50 000 simulated requests with 3 phases, 5 queries and 1 log each:
| Sample rate | Added cost per request |
|---|---|
| 0 (nothing sampled) | 0.13 µs |
| 0.1 (the default) | 1.32 µs |
| 1 (every request) | 12 µs |
On a real Fastify server (16 keep-alive clients on loopback) with a very light handler of about 83 µs, the default
rate lowered throughput by 6 to 8 % and a rate of 1 by 27 %. With a rate of 0 no loss was measurable. A handler that takes
a few milliseconds loses well under 1 % at the default rate, because the added cost is a few microseconds per request.
Measure your own app before raising sampleRate.
Options
Section titled “Options”All of them are optional. Only enabled must be set; the path and first admin come from the environment.
| Option | Default | Meaning |
|---|---|---|
enabled | false | Turn the monitor on in production. |
path | DEVTOOLS_PATH | The dashboard path. Prefer the environment variable. |
sampleRate | 0.1 | Share of requests captured fully, 0 to 1. |
slowRequestMs | 1000 | An unsampled request at least this slow is kept as a summary. |
slowQueryMs | 200 | A query this slow updates its shape’s slowest example even outside a sampled request. |
maxRequests | 200 | Sampled requests kept in memory per process. |
requestRetentionHours | 24 | How long stored samples are kept. |
maxStoredSamplesPerMinute | 120 | Most samples one process writes per minute. |
reportIntervalMs | 10000 | How often each process writes its report. |
trustedProxies | [] | Proxies whose forwarded headers are believed. |
requireHttps | true | Answer only HTTPS requests. Turn off only to try it locally. |
allowedIps | [] | When set, only these IPs or CIDR ranges reach the dashboard. |
origin | null | The public origin (https://app.example.com), for the CSRF check and passkeys. |
session.idleMinutes | 30 | Signed out after this many idle minutes. |
session.maxHours | 8 | Signed out after this many hours. |
twoFactor | "admins" | "off", "admins" or "everyone". |
passwords.minLength | 8 | Shortest password in characters; a whole number from 8 to 72. |
passwords.rejectCommon | true | Refuse passwords from the built-in common list. |
rateLimits.windowMinutes | 15 | The sliding window for failed sign-ins. |
rateLimits.account | 5 | Failures per account before it is refused for the window. |
rateLimits.ip | 20 | Failures per IP before it is refused for the window. |
rateLimits.global | 100 | Failures in total before the whole dashboard answers 404. |
rateLimits.lockMinutes | 15 | How long that lock lasts. |
explain.executing | false | Allow executing plans. See EXPLAIN. |
panels | {} | Turn tabs on or off by id. |
logLevels | ["warn", "error"] | Log levels the Logs tab keeps outside sampled requests. |
auditRetentionDays | 90 | How long audit entries are kept. |
passkeys.rpName | "Warlock monitor" | The name authenticators show. |
passkeys.rpId | host of origin | The WebAuthn relying party id. |
share.enabled | false | Turn on read-only share links. |
share.maxDays | 30 | The longest life an admin may give a link, in days (1 to 365). |
An invalid value stops the boot with DT007, naming the option.
Startup errors
Section titled “Startup errors”When the monitor is enabled but cannot start safely, the app refuses to boot with a DevtoolsProductionConfigError.
A deploy fails at once instead of exposing a half-protected dashboard. DEVTOOLS_CONFIG_CODES lists the messages.
| Code | Message and fix |
|---|---|
DT001 | Needs a dashboard path. Set DEVTOOLS_PATH (for example /ops-7f3k2q) or devtools.production.path. |
DT002 | The path must start with /, be at least 8 characters, use only letters, digits, -, _, ., ~ and /, and not be /__warlock. |
DT003 | No admin yet. Set DEVTOOLS_ADMIN_EMAIL with DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, or run warlock devtools:reset-admin --email <email>. |
DT004 | DEVTOOLS_ADMIN_PASSWORD breaks the password rules (at least passwords.minLength characters, 8 by default; at most 72 bytes; not a common password unless passwords.rejectCommon is false; not the email). Choose another one. |
DT005 | The accounts are stored in the database. Install @warlock.js/cascade and configure a database connection. |
DT006 | Two-factor secrets are encrypted with the app key. Set encryption.key (64 hex characters) in src/config/encryption.ts. |
DT007 | An option has an invalid value (share.maxDays must be a whole number from 1 to 365). The message names the option and the accepted values. |
DT008 | The devtools tables are missing (devtools_shares too, when share.enabled). Add devtoolsMigrations to database.migrations in warlock.config.ts and run warlock migrate. |
DT009 | Set either DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, not both. |
DT010 | DEVTOOLS_SETUP_TOKEN must be at least 32 characters. Generate one with openssl rand -base64 32. |
Troubleshooting
Section titled “Troubleshooting”Every dashboard URL answers 404
Section titled “Every dashboard URL answers 404”That is by design: the dashboard hides itself. A 404 can mean:
- The monitor is not enabled (
production.enabledis nottrue) or the app was not restarted after changing it. - The dashboard is disabled by an admin. Run
warlock devtools:enable. - The dashboard is locked after too many failed sign-ins. It reopens after
rateLimits.lockMinutes, or runwarlock devtools:enable. - The request is not HTTPS. Behind a proxy, set
trustedProxiesand forwardX-Forwarded-Proto. - The client IP is not in
allowedIps, or the proxy hides the real IP. ChecktrustedProxiesandX-Forwarded-For. - You have no session. Only the login page is public; open
<path>/, not a deeper URL. - The path is wrong. It must match
DEVTOOLS_PATHexactly.
Most of these cases write nothing to the server log, because that is what keeps the 404 uniform. Check, in this order:
- The boot line says whether the monitor mounted:
devtools production monitor mounted at /ops-… (DEVTOOLS_PATH)(moduledevtools, actionready). If it is missing, look for the startup error (see Startup errors). - The audit log (Admin, Audit) has
dashboard.disabled,dashboard.lockedandlogin.blockedentries for the disabled and locked cases.warlock devtools:enablewritesdashboard.enabled. - Two cases are written to the server log (module
devtools, at most one line a minute), and the dashboard is closed while they last:The devtools dashboard state could not be read and the dashboard is closed: <reason>: the database is unreachable or the tables are missing.The devtools session could not be checked and the request was refused: <reason>: the session lookup failed.
Not HTTPS, a client IP outside allowedIps, a missing session, a wrong path and a tab that is turned off leave no entry
by design.
The live view does not update
Section titled “The live view does not update”A proxy is buffering the stream. Turn buffering off for the dashboard path (see Behind a proxy). The other tabs refresh by polling and keep working.
Explain says the query is on another instance
Section titled “Explain says the query is on another instance”Only the process that ran the query can explain it. Try again, or pick that process in the instance picker.
Passkeys are not offered
Section titled “Passkeys are not offered”Install @simplewebauthn/server. Without it the dashboard offers the authenticator app only.