The store

On this page

The store

With BoxLang+ or a trial, Lens saves data to disk so it survives a restart, and so many servers can share one folder. This page describes what is written and the rules that keep it safe. The store holds redacted data only.

One owner

One component, StoreService, is the only code that writes saved data. Collectors and stores hand it records and snapshots, and it writes them on its own daemon thread, so a request never waits for a disk. The queue is bounded (store.queueSize): when it is full the record is dropped and counted, never blocked. The same thread prunes and removes the folders of servers that stopped writing. The heartbeat has a thread of its own, so a slow disk during a snapshot or a prune cannot make a server look dead. A test fails the build when another class writes files.

Behind it is a small interface, PersistentStore, that speaks in streams, snapshots and server ids and never in paths or file formats. The files described below are one implementation of it, so the storage can change without touching the collectors.

Layout

store.dir/
  web-a/                       one folder per server
    instance.json              who this is and when it last wrote
    errors.json                a snapshot, replaced as a whole
    reports.json
    http-2026-10-11.jsonl      a stream: one UTC day per file, one JSON record per line
  • A server writes only into its own folder. Many servers can share one volume (NFS, EFS) without locks. The one time a server removes anything outside its folder is a peer folder whose lease is provably stale (see Retention and size).
  • The folder is shared, so what is in it is not trusted. Symbolic links are never followed: a link in a server folder is not read, not written through, not counted and not deleted through, and a server folder that is a link is ignored. Another server's files are read up to 16 MB (64 KB for instance.json, 1 MB for a line of a stream) and 64 levels of nesting; a file over those limits, or one that is not JSON, counts as missing.
  • A record carries ts (epoch milliseconds). The UTC day of ts decides the file.
  • Snapshots are written to a temporary file and renamed. A snapshot is flushed to disk before the rename. A crash can leave one torn last line in a .jsonl file, which readers skip and the next append ends with a newline, so the torn line never swallows a new record. A temporary file a crash left behind is removed after an hour.
  • Names are limited to letters, digits, dot, underscore and dash (server ids) and lowercase letters, digits and dash (streams and snapshots). Anything else is refused, so a name from a request can never leave the folder.

What is saved

FileKindWhat
instance.jsonsnapshotWho this server is and when it last wrote (the heartbeat).
errors.json, reports.jsonsnapshotThe error groups and the report totals. reports.json also holds the run block (counts, status classes, latency bucket counts) and the 50 busiest and 25 most expensive URLs with their latency counts, which other servers read. It also says how many minutes of the minute series it keeps (keepMinutes), so a reader knows how far a trend reaches.
http-rollup-YYYY-MM-DD.jsonsnapshot per dayThe outgoing HTTP calls of one UTC day in buckets of ten minutes. Each bucket has totals, a record per host and a record per endpoint (at most 50 hosts and 100 endpoints per bucket, the rest are (other)). A record holds the number of calls, timeouts, total and maximum time, bytes, calls from requests, the counts of 2xx, 3xx, 4xx, 5xx and failed calls, and a latency histogram with the bounds 5, 10, 25, 50, 100, 250, 500 ms and 1, 2.5, 5, 10, 30 s. Counts and histograms add up, so another server can merge them. The file is rewritten about every 30 seconds.
reports-rollup-YYYY-MM-DD.jsonsnapshot per dayThe history of the Reports page for one UTC day: slices of five minutes for the whole server and, for each clock hour, the tallies of up to 50 URLs plus (other) (a method and a path with ids collapsed, never a query string). A tally is a list of counters: requests, failed, slow, total and slowest time, queries, query time, outgoing calls, exceptions, six status classes and 12 latency counts, so tallies add up across hours and servers. A day is at most a few hundred KB. When an hour has more URLs, the one outside the top by hits, by time and by failures is folded into (other). Rewritten about every 30 seconds while the day changes, pruned with the other days.
ai-rollup-YYYY-MM-DD.jsonsnapshot per dayThe AI numbers of one UTC day in buckets of ten minutes. A bucket holds a record per group (run:agent, model:provider/model, tool:name, at:agent/tool, mcps:server and so on) with the calls, errors, total and maximum time, tokens and a latency histogram (the bounds of the HTTP rollup). Counts and histograms add up across servers.
ai-consumers.jsonsnapshotThe heaviest clients of the rate limit of each MCP server hosted with bx-ai, since BxLens first saw them (at most 50 per server): the client (an IP or a short hash, never a key), requests, blocked, the busiest minute and the last block. It feeds "All time" in the top consumers.
console-sessions.jsonsnapshotThe console sign ins this server holds and the ones it ended, as hashes only. See Console sessions.
ai-runs-YYYY-MM-DD.jsonlstreamOne line per finished run or call with its steps and, when content capture is on, its redacted prompt and answer. The list of runs is filled again from it after a restart.
http-calls-YYYY-MM-DD.jsonlstreamOne line per outgoing call (time, method, host, path pattern, status, time, size, source, request id), written at collect.level full. No query string, header or body.

Console sessions

When several containers serve the console behind one address, a sign in on one of them must be good on all of them, and a sign out must end the session everywhere. Where the sessions are kept is console.sessionStorage: this server's memory ("memory", the default), a BoxLang cache ("cache", on bxSessions by default) or the store ("store", this section). A session is kept in that one place and no server keeps a copy of it in its own memory. Several servers compares them. This section describes the store.

With console.sessionStorage "store", every container must mount the same store.dir volume. It needs the disk store (BoxLang+, see Licensing). Free is one server only and keeps its sessions in memory. Sticky sessions at the load balancer also work, with or without the shared volume.

How it works:

  • Each server keeps the sessions it opened in its own console-sessions.json and never writes another server's file. A server that gets a session it does not know reads the files of the other servers. Because it may write only its own file, it records the session there when it is used, so the time of the last use is not lost. The session stays valid in every file until it is signed out or runs out.

  • A server reads its own file back when it starts, before it writes anything, so the sign outs it saved survive a restart. While its own file cannot be read it writes nothing and takes over no session.

  • Every write is made at once, one at a time, from the state as it is when it is written, so an older copy of the file can never land after a newer one.

  • Only hashes are saved. The file holds a hash of each session id, the role, and two times. The session id itself and the CSRF token are never written. The CSRF token is derived from the session id with a one way hash, so every container computes the same one.

  • Set BXLENS_SECRETS_KEY on every container, with the same value. Then the hash is keyed: an HMAC-SHA256 with a key derived from BXLENS_SECRETS_KEY (the key of the Secret Store), so someone who can write into the store folder still cannot add a session, because without the key no hash they write matches a cookie. The key never leaves the Secret Store and is never written to the store folder. Without the variable a plain SHA-256 hash is used, and write access to the folder is then enough to add a session. The key file secrets.key is not used for this, because each container may have one of its own.

  • Each file names the kind of hash it holds (keyId: plain, or keyed: and a short fingerprint that tells nothing about the key). A container ignores the file of a container that uses another key, or none, and writes a warning to the log once, because no sign in from there could match. Adding, changing or removing BXLENS_SECRETS_KEY therefore signs everyone out once.

  • A sign in is saved before the page gets its answer. The time of the last use is saved at most every 30 seconds.

  • A cookie that is not shaped like a session id (43 characters of base64url) is refused before any file is read, and the list of servers is read at most once a second.

  • A sign out ends the session everywhere. The server that signs out removes the session from its file and saves a revoked entry. Every server checks the revoked entries of all servers, so no container accepts the session again. Changing a password, which ends the other sessions of that role, revokes the sessions held by every container, also the ones this container never saw. A revoked entry is kept for one idle limit (console.sessionMinutes) and ten minutes after the sign out: after a sign out nobody uses the session, so by then it has run out on every container. Revocations leave by age only, so many newer sign outs cannot push an older one out (a guard of 20,000 per server stops a file from growing without end). Keep console.sessionMinutes the same on every container.

  • When the store cannot be written, a sign out says so. The session ends on this container at once, the answer is 503 with signedOutHere, the audit log gets logout.unsaved, and the revocation is written again a few seconds later at the next use of any session. A password change that cannot tell the other containers writes session.revoke.unsaved, and a sign in that cannot be saved is refused (503, audit login.unavailable and session.login.unsaved).

  • A sign out reaches the other containers within about one second, because a server trusts the file of another server for one second before it reads it again.

  • The idle time and the 12 hour maximum count across containers. The newest use on any container is the last use.

  • If the folder cannot be read, a session this container does not already hold is refused. A session it holds in memory keeps working with the last state it read, so a short problem with the volume does not sign everyone out. While it cannot be read, a sign out on another container does not reach this one.

  • A server skips fields it does not understand. A wrong role, a hash of the wrong length, a time that is not a number, a time more than a minute ahead of this server's clock, or a last use before the sign in makes that entry count as missing. Two files that give the same session different roles make it refused.

  • The client address a session carries, for the audit log and Lensy, is the one of the request it is read for. It is not stored.

  • When the place of the sessions changes (console.sessionStorage changed, the disk store off, or the license gone), the sessions in the store are no longer read, so people sign in again. Nothing is copied to the new place.

  • A restart of a container does not have to sign people out: a container reads its own file back when it starts, so its sessions are still there. Do not rely on it.

  • The audit log names the ending of sessions on other containers session.revoke, with the role only.

  • The login lockout is per container. Wrong passwords are counted by each container on its own, so behind a load balancer that spreads requests an attacker gets console.maxLoginAttempts guesses on each container. With several servers, rate limit the sign in at the edge: for example a Cloudflare rate limiting rule on POST /~bxlens/index.bxm/login (a few requests a minute per client address), or the same rule in your load balancer or proxy. Sticky sessions also keep one client on one container's counter.

The store volume must NEVER be web accessible

Do not put it inside a web root, do not serve it with a web server or a static file route, do not share it with other applications, and do not mount it into containers that are not part of the console. Whoever can read the folder sees the data of every server. Without BXLENS_SECRETS_KEY, whoever can write into it can add a console session, which is the same as signing in as an administrator; with it, they can still damage or delete the data. Give the volume to the BxLens containers only, with the permissions of the account that runs BoxLang.

The name of the folder

store.instanceFolder, then BXLENS_INSTANCE_FOLDER, then the host name. It must be different for every server that shares store.dir, and it should stay the same for one server across restarts. See Containers and replicas. At start BxLens logs the folder it uses and where the name came from.

Retention and size

RuleDefaultWhat happens
store.retentionDays15 (30 at most)A server removes its own day files older than this.
store.maxMB500When the whole folder is bigger, a server removes its own oldest days, down to its fair share of the cap (the cap divided by the number of server folders). A server never deletes a peer's day files, so the open file of a live peer is never taken from it. The cap wins over the retention. Each server trims in its turn, so a folder over the cap comes back under it after every server has pruned once.
store.staleAfterHoursthe retentionAny server removes the folder of a server only when the lease is provably stale: the heartbeat is older than this and nothing in the folder (file or folder time) has changed since. A heartbeat dated in the future, an unreadable one with recent files, a folder with files Lens did not write, and a folder with a link in it are left alone.

These three rules are set in boxlang.json only. The Storage tab of the console shows them read only, and POST /api/settings refuses them, because they delete data of other servers.

Pruning runs every ten minutes and at the first start. Reading a stream looks at no more than the last 32 days and, for one day, at the last 16 MB of the file.

Two servers, one name

Each server writes instance.json every 30 seconds, from its own thread. The first server to start creates it in one atomic step, so two servers that start together cannot both win. If the file shows another host that wrote in the last 90 seconds, or another live process on the same host, this server does not write and logs a warning once. It takes over when the other has been quiet for 90 seconds.

  • A clean shutdown releases the lease, so a restart is not a conflict even under another host name (a new pod name, for example). After a hard kill a restart under another host name waits for the lease to run out, up to 90 seconds after the first look.
  • The lease is judged by changes seen on our own clock, not by comparing clocks: a lease that changes between two looks is alive, and one that does not change for 90 seconds is dead. Only the first look uses the time written in the file, and a clock off by up to 5 minutes does not matter there.
  • A restart on the same host is not a conflict. Two containers that share a host name and both run as pid 1 are told apart by a token in the file. Give every server its own store.instanceFolder.

Containers

  • Mount a volume on store.dir. Without one the data is lost when the container is replaced. Lens logs a warning when it sees the folder on the container's own file system (Linux only). It never refuses to save.
  • The folder must be writable by the user of the process. Only store.dir is written.
  • On shutdown the queue is written before the module stops. A hard kill loses at most the last seconds.
  • Locks are not used on purpose, they are unreliable on network volumes. The one writer rule and the heartbeat replace them.
  • A full disk or a read only volume is counted (failed, dropped) and never blocks a request.

Windows

The store runs on Windows, and a volume shared with Linux servers can be mounted there. Rules that make that safe:

  • A folder name cannot be a Windows device name (con, prn, aux, nul, com1 to com9, lpt1 to lpt9, with or without an extension) or end in a dot. Lens refuses such a name from store.instanceFolder and BXLENS_INSTANCE_FOLDER, and falls back to the next choice.
  • Windows and macOS compare folder names without regard to case. Web-A and web-a are the same folder there, so keep names consistent across servers. The heartbeat lease still catches two live servers that end up in one folder.
  • Files are replaced with an atomic rename. Readers open files in a way that lets them be replaced, so a server reading another server's snapshot never blocks its writer.
  • Tests of the store run on Windows in CI.

What else is in the folder

Besides the files above, each server writes health.json (the health snapshot, every minute, with the identity of the server: group, kind and the BoxLang, Java and BxLens versions, and a trend part of 15 CPU and 15 heap percentages, one a minute, for the Overview), notifications.json (the notification settings of the cluster), alert-state.json, reports-state.json and daily-YYYY-MM-DD.json (the numbers the email reports are made from). The monthly report needs store.retentionDays of 30 to see the whole month. See Backup, retention and disk usage for the list and what to back up.

What it is not

It is not a database and has no query language.

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