Environment Variables

Environment variables for configuring Zentinel and its agents.

Zentinel Proxy

Configuration

VariableDescriptionDefault
ZENTINEL_CONFIGPath to configuration fileNone (uses embedded default)

Logging

VariableDescriptionDefault
RUST_LOGLog level filter (trace, debug, info, warn, error)info
ZENTINEL_LOG_FORMATLog output format (json or pretty)json

Examples:

# Set log level
export RUST_LOG=debug
export RUST_LOG=zentinel=debug,pingora=info

# Use pretty format for development
export ZENTINEL_LOG_FORMAT=pretty

Log Level Syntax

The RUST_LOG variable supports fine-grained control:

# Global level
RUST_LOG=debug

# Per-module level
RUST_LOG=zentinel=debug,pingora=warn

# With target filtering
RUST_LOG=zentinel::proxy=trace,zentinel::agents=debug

Configuration Overrides

Some configuration settings can be overridden via environment variables. Environment variables take precedence over config file values.

VariableConfig SettingDescription
ZENTINEL_WORKERSserver.worker-threadsNumber of worker threads
ZENTINEL_MAX_CONNECTIONSserver.max-connectionsMaximum connections

Example:

# Override worker threads regardless of config file
export ZENTINEL_WORKERS=8
zentinel --config zentinel.kdl

Agent Environment Variables

Echo Agent

VariableDescriptionDefault
ECHO_AGENT_SOCKETUnix socket path/tmp/echo-agent.sock
ECHO_AGENT_GRPCgRPC address (alternative to socket)None
ECHO_AGENT_LOG_LEVELLog levelinfo
ECHO_AGENT_PREFIXHeader prefix for echo headersX-Echo-
ECHO_AGENT_VERBOSEEnable verbose outputfalse

Rate Limit Agent

VariableDescriptionDefault
RATELIMIT_AGENT_SOCKETUnix socket path/tmp/ratelimit-agent.sock
RATELIMIT_AGENT_CONFIGRate limit configuration fileNone
RATELIMIT_AGENT_LOG_LEVELLog levelinfo
RATELIMIT_AGENT_DEFAULT_RPSDefault requests per second100
RATELIMIT_AGENT_DEFAULT_BURSTDefault burst size200
RATELIMIT_AGENT_DRY_RUNLog decisions without enforcingfalse
RATELIMIT_AGENT_CLEANUP_INTERVALCleanup interval (seconds)60

Custom Agents

When building custom agents using the agent template:

VariableDescriptionDefault
AGENT_SOCKETUnix socket path/tmp/{agent-name}.sock
AGENT_LOG_LEVELLog levelinfo

Docker Environment

When running Zentinel in Docker, pass environment variables:

docker run -d \
  -e ZENTINEL_CONFIG=/etc/zentinel/zentinel.kdl \
  -e RUST_LOG=info \
  -e ZENTINEL_LOG_FORMAT=json \
  -v /path/to/config:/etc/zentinel \
  zentinel:latest

Docker Compose:

services:
  zentinel:
    image: zentinel:latest
    environment:
      - ZENTINEL_CONFIG=/etc/zentinel/zentinel.kdl
      - RUST_LOG=info
      - ZENTINEL_LOG_FORMAT=json
    volumes:
      - ./config:/etc/zentinel:ro

Kubernetes Environment

Use ConfigMaps and Secrets for environment variables:

apiVersion: v1
kind: ConfigMap
metadata:
  name: zentinel-config
data:
  RUST_LOG: "info"
  ZENTINEL_LOG_FORMAT: "json"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: zentinel
spec:
  template:
    spec:
      containers:
        - name: zentinel
          envFrom:
            - configMapRef:
                name: zentinel-config

systemd Environment

For systemd services, use an environment file:

/etc/zentinel/environment:

ZENTINEL_CONFIG=/etc/zentinel/zentinel.kdl
RUST_LOG=info
ZENTINEL_LOG_FORMAT=json

/etc/systemd/system/zentinel.service:

[Service]
EnvironmentFile=/etc/zentinel/environment
ExecStart=/usr/local/bin/zentinel

Precedence

Configuration values are resolved in this order (highest to lowest priority):

  1. Command-line arguments
  2. Environment variables
  3. Configuration file values
  4. Default values

Debugging Environment Issues

Check which environment variables are set:

# Linux/macOS
env | grep -E '^(ZENTINEL|RUST_LOG)'

# Show effective configuration
zentinel --test --verbose --config zentinel.kdl

Security Considerations

  • Avoid storing secrets in environment variables when possible
  • Use Docker/Kubernetes secrets for sensitive values
  • Environment variables may be visible in process listings
  • Consider using configuration files with appropriate permissions for secrets

See Also