Skip to content

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.

In production the package must be installed, so it is a regular dependency (not a development one):

Terminal window
npm install @warlock.js/devtools

Register the connector, the migrations and the commands in warlock.config.ts:

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:

src/config/devtools.ts
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:

Terminal window
npx warlock migrate

The 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.

VariableRequiredMeaning
DEVTOOLS_PATHYesThe dashboard path, for example /ops-7f3k2q9x. Starts with /, at least 8 characters, only letters, digits and - _ . ~ /.
DEVTOOLS_ADMIN_EMAILWhile no admin existsThe first admin.
DEVTOOLS_ADMIN_PASSWORDOne of these two while no admin existsA first password. It works until it is changed at the first sign-in, which is forced. It must pass the password rules.
DEVTOOLS_SETUP_TOKENOne of these two while no admin existsAt 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.

With DEVTOOLS_ADMIN_PASSWORD:

  1. Open https://<your-app><path>/ and sign in with DEVTOOLS_ADMIN_EMAIL and the password.
  2. The dashboard asks you to choose a new password. The environment password is never applied again.
  3. Scan the QR code with an authenticator app and enter the 6-digit code. Or add a passkey, if passkeys are available.
  4. 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.

RoleCan do
viewerRead every enabled tab. Manage their own account, password, second factors and sessions.
adminEverything 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.

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/auth uses). Without it the dashboard offers the authenticator app only. Set passkeys.rpId and origin when 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.

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.

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:

src/config/devtools.ts
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.

If no admin can sign in, run on the server:

Terminal window
npx warlock devtools:reset-admin --email you@example.com

It 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.

Many apps run as several processes (pm2 cluster workers, several machines). Everything shared lives in the database:

Shared by every instancePer instance
Accounts, sessions, invites, audit log, the disable switchThe live event stream (new requests and logs as they happen)
Stored request samplesThe in-memory list of sampled requests
Resource history, query and route statistics, errors, health, jobs, merged from each instance’s reportThe 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.

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.

Nothing that leaves the process (the API, the database, the live stream) carries a value:

ItemKeptRemoved
RequestId, method, path (no query string), route pattern, status, timing, error message and stackHeaders, body, query string, params; quoted values, emails and { … } documents in the error
QueryConnection, driver, shape (SQL with placeholders), collection, command, timing, row count, error messageSQL literals, bindings, Mongo filter and pipeline values, caller file path
LogLevel, module, action, message, timecontext; quoted values, emails and { … } documents in error messages
PhaseName, start, durationattrs
CacheHit, miss and write countsKeys and tags
N+1Shape, count, messageCaller 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.

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 one SELECT or WITH statement 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: explain with queryPlanner verbosity for find, aggregate and count. An aggregate with $out or $merge is 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.

TabIn production
Requests, Queries, Routes, Resources, Health, Errors, Logs, JobsOn (Jobs shows each schedule’s recent runs and the queue counts)
AI Reports, Models, ErrorsOn when Panoptic is installed; see AI reports
Mail, AI Evaluate, API, ProcessesOff unless panels sets the id to true
AI Runs, AgentsDevelopment 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.

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_rollups table, part of devtoolsMigrations. After upgrading, run warlock migrate and 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-models and ai-errors are on by default, but only when Panoptic is installed and loads. Without it they are not listed. Set production.panels to turn any of them on or off by id: panels: { "ai-reports": false }, or panels: { "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: false turns the writer off, and so does turning off all three report tabs with panels.
  • 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.ai or panels.agents to true in 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, and POST /api/ai/evaluate does 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.
src/config/devtools.ts
export default {
ai: { retentionDays: 90 },
production: { enabled: true, panels: { "ai-errors": false } },
};

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.

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 rateAdded 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.

All of them are optional. Only enabled must be set; the path and first admin come from the environment.

OptionDefaultMeaning
enabledfalseTurn the monitor on in production.
pathDEVTOOLS_PATHThe dashboard path. Prefer the environment variable.
sampleRate0.1Share of requests captured fully, 0 to 1.
slowRequestMs1000An unsampled request at least this slow is kept as a summary.
slowQueryMs200A query this slow updates its shape’s slowest example even outside a sampled request.
maxRequests200Sampled requests kept in memory per process.
requestRetentionHours24How long stored samples are kept.
maxStoredSamplesPerMinute120Most samples one process writes per minute.
reportIntervalMs10000How often each process writes its report.
trustedProxies[]Proxies whose forwarded headers are believed.
requireHttpstrueAnswer only HTTPS requests. Turn off only to try it locally.
allowedIps[]When set, only these IPs or CIDR ranges reach the dashboard.
originnullThe public origin (https://app.example.com), for the CSRF check and passkeys.
session.idleMinutes30Signed out after this many idle minutes.
session.maxHours8Signed out after this many hours.
twoFactor"admins""off", "admins" or "everyone".
passwords.minLength8Shortest password in characters; a whole number from 8 to 72.
passwords.rejectCommontrueRefuse passwords from the built-in common list.
rateLimits.windowMinutes15The sliding window for failed sign-ins.
rateLimits.account5Failures per account before it is refused for the window.
rateLimits.ip20Failures per IP before it is refused for the window.
rateLimits.global100Failures in total before the whole dashboard answers 404.
rateLimits.lockMinutes15How long that lock lasts.
explain.executingfalseAllow executing plans. See EXPLAIN.
panels{}Turn tabs on or off by id.
logLevels["warn", "error"]Log levels the Logs tab keeps outside sampled requests.
auditRetentionDays90How long audit entries are kept.
passkeys.rpName"Warlock monitor"The name authenticators show.
passkeys.rpIdhost of originThe WebAuthn relying party id.
share.enabledfalseTurn on read-only share links.
share.maxDays30The longest life an admin may give a link, in days (1 to 365).

An invalid value stops the boot with DT007, naming the option.

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.

CodeMessage and fix
DT001Needs a dashboard path. Set DEVTOOLS_PATH (for example /ops-7f3k2q) or devtools.production.path.
DT002The path must start with /, be at least 8 characters, use only letters, digits, -, _, ., ~ and /, and not be /__warlock.
DT003No admin yet. Set DEVTOOLS_ADMIN_EMAIL with DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, or run warlock devtools:reset-admin --email <email>.
DT004DEVTOOLS_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.
DT005The accounts are stored in the database. Install @warlock.js/cascade and configure a database connection.
DT006Two-factor secrets are encrypted with the app key. Set encryption.key (64 hex characters) in src/config/encryption.ts.
DT007An 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.
DT008The devtools tables are missing (devtools_shares too, when share.enabled). Add devtoolsMigrations to database.migrations in warlock.config.ts and run warlock migrate.
DT009Set either DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, not both.
DT010DEVTOOLS_SETUP_TOKEN must be at least 32 characters. Generate one with openssl rand -base64 32.

That is by design: the dashboard hides itself. A 404 can mean:

  • The monitor is not enabled (production.enabled is not true) 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 run warlock devtools:enable.
  • The request is not HTTPS. Behind a proxy, set trustedProxies and forward X-Forwarded-Proto.
  • The client IP is not in allowedIps, or the proxy hides the real IP. Check trustedProxies and X-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_PATH exactly.

Most of these cases write nothing to the server log, because that is what keeps the 404 uniform. Check, in this order:

  1. The boot line says whether the monitor mounted: devtools production monitor mounted at /ops-… (DEVTOOLS_PATH) (module devtools, action ready). If it is missing, look for the startup error (see Startup errors).
  2. The audit log (Admin, Audit) has dashboard.disabled, dashboard.locked and login.blocked entries for the disabled and locked cases. warlock devtools:enable writes dashboard.enabled.
  3. 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.

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.

Install @simplewebauthn/server. Without it the dashboard offers the authenticator app only.