Environment Variables

Environment variables for configuring Sentinel and its agents.

Sentinel Proxy

Configuration

VariableDescriptionDefault
SENTINEL_CONFIGPath to configuration fileNone (uses embedded default)

Logging

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

Examples:

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

# Use pretty format for development
export SENTINEL_LOG_FORMAT=pretty

Log Level Syntax

The RUST_LOG variable supports fine-grained control:

# Global level
RUST_LOG=debug

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

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

Configuration Overrides

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

VariableConfig SettingDescription
SENTINEL_WORKERSserver.worker-threadsNumber of worker threads
SENTINEL_MAX_CONNECTIONSserver.max-connectionsMaximum connections

Example:

# Override worker threads regardless of config file
export SENTINEL_WORKERS=8
sentinel --config sentinel.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 Sentinel in Docker, pass environment variables:

docker run -d \
  -e SENTINEL_CONFIG=/etc/sentinel/sentinel.kdl \
  -e RUST_LOG=info \
  -e SENTINEL_LOG_FORMAT=json \
  -v /path/to/config:/etc/sentinel \
  sentinel:latest

Docker Compose:

services:
  sentinel:
    image: sentinel:latest
    environment:
      - SENTINEL_CONFIG=/etc/sentinel/sentinel.kdl
      - RUST_LOG=info
      - SENTINEL_LOG_FORMAT=json
    volumes:
      - ./config:/etc/sentinel:ro

Kubernetes Environment

Use ConfigMaps and Secrets for environment variables:

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

systemd Environment

For systemd services, use an environment file:

/etc/sentinel/environment:

SENTINEL_CONFIG=/etc/sentinel/sentinel.kdl
RUST_LOG=info
SENTINEL_LOG_FORMAT=json

/etc/systemd/system/sentinel.service:

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

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 '^(SENTINEL|RUST_LOG)'

# Show effective configuration
sentinel --test --verbose --config sentinel.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