Environment Variables

On this page

Environment variables

There are two ways to use the environment with BxLens:

  1. BxLens variables. A few fixed variables that start with BXLENS_. They name the server, its store folder and its secrets key.
  2. The BoxLang convention. BoxLang can override any setting of boxlang.json from the environment, and that includes every BxLens setting.

Set them in the environment of the server process: a service file, a Dockerfile, a Compose file or a Kubernetes manifest.

BxLens variables

VariableUsed forFalls back to
BXLENS_SERVER_NAMEThe name of this server. The registration key is tied to it.server.name, then this variable, then the host name
BXLENS_SERVER_ADDRESSThe primary address of this serverserver.address, then this variable, then the first usable IPv4 address of the machine
BXLENS_SERVER_IDA fixed id for this instanceserver.id, then this variable, then an id made from the host name and the JVM start time
BXLENS_SERVER_GROUPThe group in the fleet, for example prod-web. 1 to 32 characters of letters, digits, space, _, - and ..server.group, then this variable, then no group
BXLENS_SERVER_KINDhost, docker, swarm, kubernetes, podman, lxc, lambda, ecs, cloud-run or azureserver.kind, then this variable, then detected
BXLENS_INSTANCEThe name of this server's folder in the store. Letters, digits, ., _, -, 64 characters at most.store.instanceFolder, then this variable, then the host name
BXLENS_SECRETS_KEYThe key of the Secret Store: base64 of 32 bytes. Replaces secrets.key and is never shown.The secrets.key file

In a container the host name changes on every deploy. Set BXLENS_SERVER_NAME and BXLENS_INSTANCE to fixed values.

Variables whose name you choose

These settings hold the name of a variable, never its value. For the first two, the name must start with the prefix shown, so a setting cannot send out any other variable of the server (a license, a cloud key).

SettingThe name starts withExample
notifications.smtp.passwordEnvBXLENS_SMTP_BXLENS_SMTP_PASSWORD
channels[].urlEnv, tokenEnv, signingKeyEnvBXLENS_CHANNEL_BXLENS_CHANNEL_OPS_SLACK
registration.keyEnvany nameBXLENS_REGISTRATION_KEY
ai.apiKeyEnvany nameOPENAI_API_KEY

Passwords in boxlang.json

BoxLang replaces ${env.NAME} in boxlang.json itself. Any name works. These are the ones the documentation uses:

"console": {
    "password": "${env.BXLENS_PASSWORD}",
    "viewerPassword": "${env.BXLENS_VIEWER_PASSWORD}"
}

A default is allowed: ${env.BXLENS_PASSWORD:change-me}.

The BoxLang convention: any setting from the environment

BoxLang lets any item of its configuration be overridden from the environment or from a Java system property. The BxLens settings live under modules.bxlens.settings, so the same rule applies to them. See Environmental properties configuration in the BoxLang documentation.

The rule. Start with BOXLANG_, then the path of the setting with each dot written as _:

modules.bxlens.settings.console.sessionStorage
        |
BOXLANG_MODULES_BXLENS_SETTINGS_CONSOLE_SESSIONSTORAGE

Examples

BOXLANG_MODULES_BXLENS_SETTINGS_CONSOLE_SESSIONSTORAGE=cache
BOXLANG_MODULES_BXLENS_SETTINGS_CONSOLE_SESSIONCACHE=SESSIONS
BOXLANG_MODULES_BXLENS_SETTINGS_THRESHOLDS_SLOWQUERYMS=250

The same setting as a Java system property uses dots and the exact case, and needs the boxlang. prefix:

-Dboxlang.modules.bxlens.settings.console.sessionStorage=cache

Good to know

  • Case. The variable name is not case sensitive. BoxLang matches it to the key that is already in boxlang.json, and BxLens reads its settings without regard to case too.
  • Keys that are not in boxlang.json. They are added, and nested paths work.
  • Values. Every value arrives as a text. BxLens turns the text into a boolean or a number where the setting needs one, so true, false and 250 work.
  • Lists. A list (for example access.proxyPeers) does not arrive as a list. Set lists in boxlang.json.
  • The prefix BXLENS_SETTINGS_ is not a thing. BXLENS_SETTINGS_CONSOLE_SESSIONSTORAGE is ignored. Use the BOXLANG_MODULES_BXLENS_SETTINGS_ form.
  • Settings of the console. A setting that an admin changed in the console is kept in the settings file of the store and is a separate layer. See Configuration.
Note

This was checked on BoxLang 1.19.0 with a boxlang.json that already holds the setting. Older versions of BoxLang may not support it.

Variables of the platform

BxLens only asks whether these are set, never for their value, to tell where the server runs. Do not set them yourself.

VariableMeans
AWS_LAMBDA_FUNCTION_NAMEAWS Lambda
ECS_CONTAINER_METADATA_URI_V4, ECS_CONTAINER_METADATA_URIAWS ECS or Fargate
K_SERVICEGoogle Cloud Run
WEBSITE_SITE_NAMEAzure App Service
KUBERNETES_SERVICE_HOSTKubernetes

BxLens also reads BOXLANG_INSTANCE_NAME (the BoxLang runtime instance name), COMMANDBOX_VERSION (the CommandBox version) and, for the host name, HOSTNAME or COMPUTERNAME.

All variables on one page

VariableKind
BXLENS_SERVER_NAME, BXLENS_SERVER_ADDRESS, BXLENS_SERVER_ID, BXLENS_SERVER_GROUP, BXLENS_SERVER_KINDIdentity of the server
BXLENS_INSTANCEStore folder
BXLENS_SECRETS_KEYSecret Store key
BXLENS_SMTP_...Name you choose, for the SMTP password
BXLENS_CHANNEL_...Name you choose, for a channel address, token or signing key
BXLENS_REGISTRATION_KEYName you choose, for the registration key (example)
BXLENS_PASSWORD, BXLENS_VIEWER_PASSWORDNames you choose, for ${env.NAME} in boxlang.json (examples)
BOXLANG_MODULES_BXLENS_SETTINGS_<PATH>Any BxLens setting
BOXLANG_INSTANCE_NAME, COMMANDBOX_VERSION, HOSTNAME, COMPUTERNAMERead for the runtime and the host
AWS_LAMBDA_FUNCTION_NAME, ECS_CONTAINER_METADATA_URI(_V4), K_SERVICE, WEBSITE_SITE_NAME, KUBERNETES_SERVICE_HOSTPlatform, presence only