Running BxLens in production

On this page

Running BxLens in production

The bar is a development tool. The console can run on a live server if you set it up with care. This guide is the checklist, then the reasons. Pages for the rest of the job: Several servers, Backup, retention and disk usage, Hardening and threat model and the Alert runbook.

What changes in production

That makes three choices important: who may reach it, what is collected, and what the bar does.

The console collects every request

When the console is on, BxLens collects every request on the server, not only those from allowed callers, so the console can show real traffic. Only people who pass the access rule and sign in can read it.

The checklist

Work down the list once per environment. Each line says where to set it. The sections after it give the detail. Items marked "(boxlang.json only)" cannot be set in the console.

  •  bar.enabled is false (boxlang.json, or Settings on the console).
  •  console.enabled is true, with a password that is not in a file you commit (boxlang.json, or Settings, Security).
  •  console.access names a VPN range or a few addresses, not "all" (boxlang.json only).
  •  console.requireHttps is true, and the runtime sees the request as HTTPS (boxlang.json only).
  •  access.allowedHosts lists the host name people type. Behind a proxy, access.proxyPeers lists the proxy addresses, not the whole private network (boxlang.json only).
  •  collect.level is light (the default).
  •  Operators who only look have the viewer password (BoxLang+). Everyone else has no password.
  •  console.readOnly is true if nobody should change anything from the console, and console.actions is false if nobody should run tasks, clear caches or restart applications from it (boxlang.json only).
  •  console.allowHeapDump is false (the default).
  •  ai.enabled is false, or the provider is a model inside your network.
  •  With BoxLang+: store.dir is on a volume that outlives the server, every server has a stable store.instanceFolder (or BXLENS_INSTANCE_FOLDER), and store.retentionDays and store.maxMB are what you want to keep.
  •  secrets.dir is on a shared volume when several servers must read the same secrets, and BXLENS_SECRETS_KEY is set on every server if the key must stay off that volume.
  •  The folders in Backup, retention and disk usage are in your backup, and the key is not in the same backup as the data.
  •  You read bxlens-audit.log now and then, or ship it with your other logs.
  •  You tried the checks at the end of this page from a machine that is not allowed.

A safe starting point

{
	"modules": {
		"bxLens": {
			"settings": {
				"bar": { "enabled": false },
				"console": {
					"enabled": true,
					"password": "bxsecret:AbCdEf123...==",
					"viewerPassword": "bxsecret:GhIjKl456...==",
					"requireHttps": true,
					"access": [ "10.8.0.0/24" ],
					"sessionMinutes": 15,
					"actions": false,
					"readOnly": true,
					"allowHeapDump": false,
					"publicUrl": "https://ops.example.com/~bxlens/index.bxm"
				},
				"collect": { "level": "light" },
				"access": {
					"allowedHosts": [ "ops.example.com" ],
					"trustProxyHeader": true,
					"proxyHeader": "X-Forwarded-For",
					"proxyPeers": [ "10.0.1.5" ]
				},
				"store": {
					"dir": "/mnt/lens-store",
					"instanceFolder": "web-a",
					"retentionDays": 15,
					"maxMB": 500
				},
				"secrets": { "dir": "/mnt/lens-secrets" },
				"ai": { "enabled": false },
				"history": { "maxRequests": 100 }
			}
		}
	}
}
"password": "${env.BXLENS_PASSWORD}"

Check that the variable is set: an unset placeholder stays as literal text.

Run boxlang generatesecret "a long random password" and paste the bxsecret: value into console.password. Do the same, with another password, for console.viewerPassword. Pin the seed with BOXLANG_SECURITY_SECRETSEED if several machines share one config, see Set passwords: plain, env or bxsecret.

Leave both out of the file and set the passwords in the console after a first start with a throwaway password. The console value wins, and the page says where each password comes from.

readOnly: true and actions: false suit a console that is only for looking. Take them out when your operators need to change settings, set passwords in the console or run tasks from it. With readOnly on, a password cannot be changed from the console either: the operator edits boxlang.json.

console.publicUrl is the address people reach the console at. It gives the "Open in BxLens" link in the mails and in the messages sent to Slack, Teams, Telegram and webhooks. Leave it empty if you want no link.

What goes in boxlang.json and what in the console

console.enabled, console.access, console.requireHttps, console.readOnly, console.actions, console.allowHeapDump, console.sessionMinutes, console.publicUrl, console.overridesFile, all of access.*, bar.access, every store.*, secrets.dir, notifications.channelHosts, registration.*, server.*, async.*. A change needs a restart.

Admin only, stored in the Secret Store. The admin and viewer passwords (the viewer login is BoxLang+), the AI key and the SMTP password (write only, BoxLang+). They win over boxlang.json.

BoxLang+ to change. collect.level, bar.enabled, thresholds, collector switches, UI, limits, ai.* except the key. Saved in config/bxlens-settings.json and loaded at the next start. They win over boxlang.json.

BoxLang+. The SMTP server, recipients, alert rules, channels, report schedule. Saved in the store, so they reach every server.

A rule of thumb: what decides who can get in and what the server may delete stays in boxlang.json, where a deploy controls it. What an operator tunes on a bad day goes in the console. The full lists are in Live settings.

Step by step

  1. Keep the passwords out of the file. Use an environment variable ("password": "${env.BXLENS_PASSWORD}") or an encrypted value. For the encrypted value run boxlang generatesecret "a long random password" and paste the bxsecret: value into console.password. Do the same, with another password, for console.viewerPassword. Pin the seed with BOXLANG_SECURITY_SECRETSEED if several machines share one config, see Set passwords: plain, env or bxsecret. Never commit a plain text password. Check that the variable is set, an unset placeholder stays as literal text. Or leave both out of the file and set the passwords in the console after a first start with a throwaway password: the console value wins, and the page says where each password comes from.
  2. Give people the right role. Operators who only look use the viewer password (BoxLang+). A viewer cannot change anything, cannot download dumps, logs or the bundle, and does not get the Logs, Environment, System and Threads pages or the admin tabs of Settings, but can still read request data and queries, so keep the password private. See Roles.
  3. Limit who can reach it. Set console.access to a VPN range or a short list of IPs and CIDRs. Keep "local" if you tunnel in with SSH. Avoid "all": it works, but BxLens logs a warning. Add access.allowedHosts for the host name you use (a local rule otherwise accepts only localhost, 127.0.0.1 and [::1] as Host names), and access.requireHeader if a proxy can add a secret header. A caller who is not allowed gets a plain 404.
  4. Use HTTPS and require it. Set console.requireHttps to true. Terminate TLS in front of the runtime and make sure the runtime sees the request as secure: either it reports HTTPS itself, or your proxy sends X-Forwarded-Proto: https from an address in access.proxyPeers. Check the cookie in your browser tools (it must be Secure). Loopback callers are exempt, so an SSH tunnel to the server still works over HTTP.
  5. Say which proxies to trust. Behind a proxy or load balancer, set access.proxyPeers to the addresses of your proxies, not the whole private network, so only they can name the client address. Without a proxy, set access.trustProxyHeader to false. The lockout and console.access use this address, so a wrong setting locks out everyone behind the proxy, or lets a caller choose their own address. See Behind a proxy.
  6. Collect lightly. collect.level: "light" skips request headers, bound query parameters, the caller (template and line) of queries, HTTP calls and transactions, the BoxLang frames of exceptions, scope contents, Java stack traces, and the functions, logs, scopes and bifs collectors. SQL text, timings and counts stay. It is the default. Non HTML requests are not kept in the history (history.trackNonHtml), and the history is built lazily, so a request nobody opens costs no snapshot. Use full only on a machine you control. Leave collectors.queries.includeParams off: bound values can be personal data.
  7. Turn the bar off. Leave bar.enabled false. Developers do not need a strip injected into live pages.
  8. Decide on changes. Set console.actions to false if nobody should run, pause or reload tasks, clear caches, restart applications, start or stop watchers or requeue mail from here (most of these also need BoxLang+). Set console.readOnly to true if nobody should change anything from the console. The pages stay readable.
  9. Keep heap dumps off. Heap dumps need BoxLang+ or a trial. Leave console.allowHeapDump at false. A heap dump holds every secret in memory. Turn it on for the time you need it, then off. See Heap dumps.
  10. Decide on AI. Leave ai.enabled false, or use a local provider so prompts stay in your network. See AI data flow.
  11. Put the store on a volume. With BoxLang+ or a trial, errors, reports and the notification settings are saved to store.dir. In a container, mount a volume there, or the data is lost when the container is replaced (BxLens logs a warning when it sees the folder on the container's own file system). Give each server a stable name with store.instanceFolder or BXLENS_INSTANCE_FOLDER. Set store.retentionDays and store.maxMB to what you want to keep. See The store and Backup, retention and disk usage.
  12. Hide what you do not need. tabs.hide removes pages, for example ["threads", "designer", "environment"].
  13. Size the history. history.maxRequests is the memory you spend. Each request holds its full snapshot in memory. On Free the history is capped at 25. Watch the heap on the System page after you raise it.
  14. Watch the audit log. bxlens-audit.log in the logs directory records logins, failed logins, denied attempts and every change. Read it on the Logs page or ship it with your other logs. The Security alert (BoxLang+) mails you when failed logins pile up.
  15. Set up alerts. With BoxLang+, switch on the alerts you need in Settings, Notifications, after you have a feel for the normal numbers. The Alert runbook says what each one means and what to check.

What is bounded in memory

Every store has a hard cap and drops the least recently seen entry. This is what you budget for.

WhatCap
Request historyhistory.maxRequests (default 250, 25 on Free). The only large one: it holds full snapshots
Query statistics500 statements
Error issues200 issues, 5 events each, 20 new kinds a minute, 1000 events a second. See errors in a flood
Report URLs300
Outgoing HTTP calls list500 calls, at collect.level full
Mail messagescollectors.mail.maxMessages (200), 10 on Free
AI runscollectors.aiobs.maxRuns (500)
Cache keys on the Caches page100 per cache, values cut at 2 KB
Log lines per read2000
Console sessions200
Live streamsconsole.maxStreams (10)
Background work queueasync.queueSize (2000 tasks), then new work is dropped and counted
Disk writes queuestore.queueSize (20000 records), then new records are dropped and counted

Disk is covered in Backup, retention and disk usage. The figures for the time a request costs are in Performance, and how it behaves under heavy traffic and error floods is in Performance under load.

Work off the request thread

How the background worker behaves

A collector never blocks and never throws into a request, and heavy aggregation is async. When a request ends, Lens closes its spans, takes its status and, if the bar shows, builds the payload for the page. Everything else is queued for one daemon thread (bxlens-worker): the query statistics, the error groups, the reports, the history entry and the audit log lines. Issue analysis is not done at all until the console opens a request.

  • The queue is bounded (async.queueSize, default 2000). When it is full the new task is dropped and counted. A request never waits for it.
  • A task that fails is counted and forgotten. The worker keeps going.
  • Tasks run in order. Pages of the console and the data BIFs wait (up to a second) for the queue to catch up before they read, so they always include the request that just ended.
  • At shutdown the queue drains (up to three seconds) before the statistics are saved.
  • The depth, the number of finished tasks and the dropped count are on the console Overview and System pages and in lensDiagnostics(). A dropped count that keeps growing means the server is busier than the worker. Raise async.queueSize or turn collection down with collect.level.
  • async.enabled: false does the work in the request again.

The files of the bar

Bar files, caching and CSP

A page that shows the bar gets a block of about a kilobyte, not the whole bar. The styles, the script, Alpine.js, the markup and the icons are five files under /~bxlens/index.bxm/assets/, with a content hash in the URL. A browser (or a CDN or proxy) keeps each for a year (Cache-Control: public, max-age=31536000, immutable) and fetches the new ones by itself after an upgrade. They hold no request data and no secret. The bar needs a Content-Security-Policy of script-src 'self' 'unsafe-eval', style-src 'self' and connect-src 'self', with no unsafe-inline.

If you proxy to BoxLang with a path filter, allow /~bxlens/index.bxm/assets/* for the people who see the bar, not only for the console.

The console URL

/~bxlens/index.bxm always works. Lens also rewrites /~bxlens and /~bxlens/ (with the trailing slash) to it, in onWebExecutorRequest. Nothing else in the public folder becomes reachable that way.

On MiniServer the request must also pass the pass predicate, or MiniServer serves it as a static path and never hands it to BoxLang. Add the console path to the default predicate, in one of two ways.

Set BOXLANG_PASS_PREDICATE to this exact value:

regex( '^(/.+?\.cfml|/.+?\.cf[cms]|.+?\.bx[ms]{0,1})(/.*)?$' ) or regex( '^/~bxlens/?$' )

Set the same string as passPredicate in miniserver.json (in JSON, write each backslash twice).

The first regex is the default MiniServer predicate and the second one lets the console path through.

MiniServer welcome files do not apply to module mappings, and the list of welcome files is not configurable in core. That is why Lens does the rewrite itself.

On CommandBox or a servlet container this was not tested. The trailing slash form works only if the path reaches the BoxLang servlet, which depends on the server's own mappings. Use /~bxlens/index.bxm there.

Check it

  • Request /~bxlens/index.bxm from a machine that is not allowed. You get a plain 404.
  • Request it over plain HTTP from an allowed non-loopback machine. You get a 403 with HTTPS is required for the console.
  • Request it from an allowed machine over HTTPS. You see the login page.
  • Sign in with the viewer password and try to change a setting. The fields are disabled, and a direct call gets a 403.
  • The Settings page shows the passwords as set, collect.level as light and console.readOnly as true.
  • The log shows bx-lens ... active: bar=false, console=true, collect=light.
  • After a restart, the Reports page still shows "Since first install" (needs BoxLang+ or a trial).

Performance and overhead

Measured cost and how to lower it

These figures were measured, not estimated. Hardware: a cloud container with 4 vCPU and 16 GB RAM, OpenJDK 21, BoxLang 1.19.0-snapshot on MiniServer, the demo harness app, 4 concurrent connections from a client on the same machine, 3 runs of 10 seconds per cell after a warm up. Your hardware and your application will differ, and a real page spends more of its time in your own code, so use the per request cost, not the percentages. The method, the raw results and the caveats are in tools/perf/README.md, and you can repeat the run with tools/perf/overhead.sh.

Cost per request over a server without the module (CPU of the whole server process, and memory allocated):

SettingExtra CPU per requestExtra allocation per request
Console collecting, bar off, collect.level light0.05 to 0.4 ms23 to 57 KB
The same with fullup to 0.9 ms33 to 440 KB (most on pages with many queries)
Bar shown to the caller (either level)0.6 to 1.0 ms more, on HTML pages only80 to 130 KB more

The measured pages were 1.2 to 2.1 ms of CPU each without the module, so the bar roughly doubled it and light without the bar added a few percent to a quarter. Latency and throughput differences were inside the spread between runs on this shared machine (p50 within about 1.5 ms, requests per second not ordered reliably), which is why the table is in CPU and memory. Do not read it as a guarantee.

To lower the overhead:

  • Turn the bar off in production (bar.enabled false, or limit bar.access). The bar is the largest single cost, and only for the callers allowed to see it.
  • Keep collect.level at light. full also records the caller of every query (a stack walk, collectors.queries.captureCaller) and bound parameters.
  • Keep history.trackNonHtml off at light (the default): requests that are not kept cost no snapshot.
  • Close console tabs you are not using. Each open console holds a request thread and, with 1000 requests in history.maxRequests, cost about 40 to 60 ms of CPU and 12 MB of allocation per second before the stream sent the list only when it changed. After that it is 21 to 25 ms and 1 to 2 MB per second on a quiet server; on a busy one the list still changes every second.
  • Leave history.maxRequests at its default unless you need more. The list is held in memory and the console reads all of it.
  • Content capture for AI and mail (collectors.aiobs.content preview or full, collectors.mail.capture full) scrubs text on the request thread: up to a few milliseconds for a 40 000 character body.

The console pages load on demand and are cheap (2 to 10 ms, under 4 KB) except the Threads page (about 90 ms, a full thread dump) and the Requests list at 1000 rows (about 20 ms, 240 KB). The minute health snapshot, the rollup writer and the notification tick run off the request thread and cost milliseconds per minute.

Not measured: the disk store under heavy write load, a ColdBox application, the AI and Mail collectors under traffic, and more than 4 connections.

Know the limits

The console is for one server. It keeps recent requests, query statistics and in-flight data in memory and loses them at a restart. With BoxLang+ or a trial, errors and reports survive restarts. For several nodes that share a store folder, BoxLang+ adds a server selector and alerts, see Several servers.

See also Security.

Edit this page Download Markdown Last updated Nov 26, 2026, 8:34:30 AM Report an issue