Environment Variables

Reference of all supported environment variables, grouped by category.

Client var prefix differs by app. Browser-exposed (client) variables are build-time inlined and the prefix depends on which dashboard you run:

AppClient prefixRead via
apps/dashboard (Next.js, legacy)NEXT_PUBLIC_*process.env.NEXT_PUBLIC_*
apps/dashboard-tsr (TanStack Start)VITE_*import.meta.env.VITE_*

Same variable, different prefix — e.g. NEXT_PUBLIC_AUTH_PROVIDERVITE_AUTH_PROVIDER, NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYVITE_CLERK_PUBLISHABLE_KEY. The tables below list the legacy NEXT_PUBLIC_* names; for the TanStack app substitute the VITE_ prefix. Worker [vars] are runtime-only and never reach the client, so these MUST be set at build time (CI build step / vite.config.ts). Authoritative TanStack reference: apps/dashboard-tsr/.env.example.


ClickHouse Connection

Required. At minimum set CLICKHOUSE_HOST.

VariableDefaultDescription
CLICKHOUSE_HOST— (required)Comma-separated ClickHouse host URLs.
CLICKHOUSE_USERdefaultComma-separated usernames.
CLICKHOUSE_PASSWORD""Comma-separated passwords.
CLICKHOUSE_NAMEComma-separated custom labels shown in the host selector.

Each position across the comma-separated values maps to the same host index. All four vars must have the same number of values.


Query Execution

VariableDefaultDescription
CLICKHOUSE_MAX_EXECUTION_TIME60Query timeout in seconds.
CLICKHOUSE_TZserver defaultTime zone for date/time formatting.
NEXT_QUERY_CACHE_TTL3600Server-side query cache TTL in seconds.
CLICKHOUSE_DATABASEsystemDatabase for app-owned tables (events, dashboards).
EVENTS_TABLE_NAMEsystem.monitoring_eventsFull override for the self-tracking events table.

Connection Pool

VariableDefaultDescription
CLICKHOUSE_POOL_SIZE10Max concurrent ClickHouse clients per host config.
CLICKHOUSE_POOL_TIMEOUT300000Idle client timeout in ms (5 min).
CLICKHOUSE_POOL_CLEANUP_INTERVAL60000Stale-client cleanup interval in ms (1 min).

Health Alerting (Cron Sweep)

The autonomous health sweep (GET /api/cron/health-sweep, triggered by the Cloudflare Cron Trigger every 5 minutes) runs the same health checks as the Health dashboard over all configured hosts and dispatches webhook alerts — even when no browser tab is open. Unlike the in-app alert settings (stored per-browser in localStorage), the cron sweep reads its configuration from env.

VariableDefaultDescription
CRON_SECRETShared secret guarding /api/cron/health-sweep. Sent as Authorization: Bearer <secret> or ?secret=. When unset, the endpoint is open.
HEALTH_ALERT_ENABLEDfalseSet to true to POST webhook alerts. When false, checks still run but no alert is sent.
HEALTH_ALERT_WEBHOOK_URLSlack/Discord-compatible webhook URL. Required for alerts to dispatch.
HEALTH_ALERT_MIN_SEVERITYwarningMinimum severity to alert on: warning (warning + critical) or critical (critical only).
# Example: alert to Slack on warning-or-worse, every 5 minutes
CRON_SECRET=a-long-random-string
HEALTH_ALERT_ENABLED=true
HEALTH_ALERT_WEBHOOK_URL=https://hooks.slack.com/services/T000/B000/XXXX
HEALTH_ALERT_MIN_SEVERITY=warning

Feature Permissions

All features are public and enabled by default. Override only what needs different behavior.

VariableDefaultDescription
CHM_CONFIG_FILEPath to TOML/YAML config file for feature overrides.
CHM_DISABLED_FEATURESComma-separated feature ids to disable.
CHM_AUTH_REQUIRED_FEATURESComma-separated feature ids that require authentication.
CHM_FEATURE_{ID}_ACCESSpublicPer-feature access level: public, guest, authenticated.
CHM_FEATURE_{ID}_ENABLEDtruePer-feature enabled/disabled flag.

Replace {ID} with an uppercase feature id: AGENT, TABLES, METRICS, SETTINGS, ACTIONS, MCP, PEERDB, INSIGHTS, SECURITY, LOGS, CLUSTER, OPERATIONS, DASHBOARD, OVERVIEW, QUERIES, HEALTH, DOCS, ABOUT.

# Examples
CHM_FEATURE_AGENT_ACCESS=authenticated
CHM_FEATURE_METRICS_ENABLED=false
CHM_FEATURE_SETTINGS_ACCESS=authenticated

See the Feature Permissions guide for full details.


Authentication

The active server-side auth provider is chosen by CHM_AUTH_PROVIDER. See the Authentication reference for the full model (public, API key, Clerk, and reverse-proxy methods).

VariableDefaultDescription
CHM_AUTH_PROVIDERnoneServer auth provider: none, clerk, proxy.
NEXT_PUBLIC_AUTH_PROVIDERnoneClient-side auth provider (mirror CHM_AUTH_PROVIDER).
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerk publishable key (pk_...).
CLERK_SECRET_KEYClerk secret key (sk_...).
CHM_API_KEY_SECRETShared secret for chm_ API keys (/api/v1/auth/api-key + MCP auth). When set, API-key auth is always on alongside the provider.

Reverse proxy (CHM_AUTH_PROVIDER=proxy)

Trust a reverse proxy that already authenticated the user. Either mechanism below authenticates a request; whichever succeeds first wins.

VariableDefaultDescription
CHM_CF_ACCESS_TEAM_DOMAINCloudflare Access team URL (https://<team>.cloudflareaccess.com). Enables Cf-Access-Jwt-Assertion JWT verification.
CHM_CF_ACCESS_AUDAccess application AUD tag the JWT must carry.
CHM_PROXY_AUTH_SECRETShared secret. When set, a trusted identity header is honored only if the request also presents this secret (constant-time compared). Set via wrangler secret put.
CHM_PROXY_SHARED_SECRET_HEADERX-Chm-Proxy-SecretHeader the proxy sets to the shared secret.
CHM_PROXY_AUTH_HEADERX-Forwarded-UserHeader the proxy sets to the authenticated user identity.

Without CHM_PROXY_AUTH_SECRET, the trusted-header mechanism is disabled — any client could forge X-Forwarded-User on a publicly-reachable worker.


AI Agent / LLM Provider

The AI agent uses an OpenAI-compatible API. At minimum set LLM_API_KEY.

VariableDefaultDescription
LLM_API_KEYProvider API key.
LLM_API_BASEhttps://openrouter.ai/api/v1API base URL.
LLM_MODELopenrouter:openrouter/freeModel identifier.

Provider-Specific

VariableDefaultDescription
ANYROUTER_API_KEYAnyRouter API key.
ANYROUTER_API_BASEAnyRouter API base URL.
OPENROUTER_API_KEYOpenRouter API key.
OPENROUTER_API_BASEOpenRouter API base URL.
OPENROUTER_REFEREROpenRouter referer header for rankings.
OPENROUTER_APP_NAMEOpenRouter app name for rankings.
OPENROUTER_MODELS_APIhttps://openrouter.ai/api/v1/modelsOpenRouter models list endpoint.
NVIDIA_API_KEYNVIDIA NIM API key.
NVIDIA_API_BASENVIDIA NIM API base URL.

Agent Behaviour

VariableDefaultDescription
AGENT_API_TOKENShared token for agent API Bearer auth.
AGENT_ENABLE_CONTROL_TOOLSfalseEnables kill-query, optimize, and other write actions.

Conversation Store

VariableDefaultDescription
AGENT_CONVERSATION_PERSISTENCEfalseEnables server-side agent conversation persistence.
AGENT_CONVERSATION_STOREautoBackend: auto, agentstate, d1, durable-object, clickhouse, postgres, memory, or local.
NEXT_PUBLIC_FEATURE_CONVERSATION_DBfalseDeprecated alias for AGENT_CONVERSATION_PERSISTENCE=true.
AGENTSTATE_API_KEYAgentState API key. Required for agentstate; must start with as_live_.
AGENTSTATE_API_BASEhttps://agentstate.app/apiAgentState API base URL.
CONVERSATIONS_D1_DATABASE_IDCloudflare D1 database UUID for the optional CONVERSATIONS_D1 binding. Required to enable D1-backed conversation storage in deployed environments.
AGENT_CONVERSATIONS_D1_DATABASE_IDAlias accepted by deploy prep for CONVERSATIONS_D1_DATABASE_ID.
AGENT_CONVERSATIONS_DO_BINDINGAGENT_CONVERSATIONS_DODurable Object binding used by durable-object.
CLICKHOUSE_AGENT_CONVERSATIONS_TABLE${CLICKHOUSE_DATABASE}.agent_conversationsClickHouse table for clickhouse store. In auto, ClickHouse is tried only when this is explicitly set.
CLICKHOUSE_AGENT_CONVERSATIONS_AUTO_CREATEtrueCreate the ClickHouse conversation table at runtime if missing.
DATABASE_URLPostgreSQL connection string for postgres.
POSTGRES_URLAlternative PostgreSQL connection string.
POSTGRES_PRISMA_URLPrisma-specific PostgreSQL connection string.

See Agent Conversation Storage for setup commands, backend permissions, and fallback behavior.


PeerDB Monitoring

Optional, view-only. Set PEERDB_API_URL to enable the PeerDB section (Mirrors and Peers) in the sidebar. When unset, the section shows a "not configured" state and the proxy returns 503.

VariableDefaultDescription
PEERDB_API_URLBase URL of the PeerDB REST API. For the PeerDB UI (NextAuth), include the /api suffix — e.g. https://peerdb.example.com/api — since it proxies /api/v1/* to the flow-api. For a raw flow-api, use the bare origin — e.g. http://localhost:8113.
PEERDB_PASSWORDPeerDB UI/API password. Sent as HTTP Basic with an empty username (base64(":" + password)). Leave empty if the API has no auth. Server-side only — never exposed to the browser.
PEERDB_CACHE_TTL_MS10000TTL for the server-side response cache (ms). Set 0 to disable.
PEERDB_CACHE_MAX_ENTRIES500Max cached responses before oldest entries are evicted.
PEERDB_FETCH_TIMEOUT_MS10000Upstream PeerDB request timeout (ms).

CHM proxies only a read-only allowlist of PeerDB endpoints (app/api/v1/peerdb/[...slug]); mutating endpoints (create/drop/pause, alert config, maintenance) are rejected with 403.

# Example: PeerDB UI behind NextAuth
PEERDB_API_URL=https://peerdb.example.com/api
PEERDB_PASSWORD=your-peerdb-ui-password

# Example: raw flow-api (no auth)
PEERDB_API_URL=http://localhost:8113

For local development without a PeerDB instance, run the bundled mock:

bun run peerdb:mock                                  # serves :8113
PEERDB_API_URL=http://localhost:8113 bun run dev

Analytics & Branding

VariableDefaultDescription
NEXT_PUBLIC_TITLE_SHORTClickHouseBrowser tab title (short form).
NEXT_PUBLIC_LOGOCustom logo URL (header branding).
NEXT_PUBLIC_AUTOCOMPLETE_LIMITMax results in autocomplete dropdowns.
NEXT_PUBLIC_MEASUREMENT_IDGoogle Analytics measurement ID (G-...).
NEXT_PUBLIC_SELINE_ENABLEDfalseEnable Seline analytics.
NEXT_PUBLIC_VERCEL_ANALYTICSfalseEnable Vercel Analytics.
NEXT_PUBLIC_POSTHOG_KEYPostHog project API key.
NEXT_PUBLIC_POSTHOG_HOSThttps://us.i.posthog.comPostHog host URL.

Runtime & Build

VariableDefaultDescription
NODE_ENVdevelopmentRuntime environment (development, production, test).
ENABLE_CLOUDFLAREfalseEnable Cloudflare-specific build configuration.
CLOUDFLARE_WORKERSSet to 1 when running on Cloudflare Workers.
CF_PAGESSet by Cloudflare Pages at runtime.
MINIFLARESet to 1 when running locally with Miniflare.
DOCS_CONTENT_ROOTOverride docs content source directory.

Build-Time

These are injected at build time for the About page:

VariableDescription
NEXT_PUBLIC_GIT_SHACurrent commit SHA.
NEXT_PUBLIC_GIT_REFCurrent git branch or tag.
NEXT_PUBLIC_BUILD_TIMESTAMPISO build timestamp.
NEXT_PUBLIC_CISet to true in CI environments.

Legacy / Migration

VariableDefaultDescription
CLICKHOUSE_CACHE_TAGLegacy cache tag override (prefer NEXT_QUERY_CACHE_TTL).
DATABASE_URLMigration / conversation store database URL.
POSTGRES_URLMigration / conversation store database URL (fallback).