Configuration Guide
Overview
AxonHub uses a flexible configuration system that supports both YAML configuration files and environment variables. This guide covers all available configuration options and best practices for different deployment scenarios.
Configuration Methods
Configuration Priority
AxonHub uses Viper for configuration management, which can read from multiple configuration sources and merges them together into one set of configuration keys and values. Viper uses the following precedence for merging (highest to lowest):
- Environment variables - System environment variables
- Config files - YAML configuration files
- External key/value stores - External configuration stores
- Defaults - Built-in default values
This means that environment variables will override values in the configuration file, and command line flags will override environment variables.
1. YAML Configuration File
Create a config.yml file:
# config.yml
server:
port: 8090
name: "AxonHub"
db:
dialect: "sqlite3"
dsn: "file:axonhub.db?cache=shared&_fk=1"
log:
level: "info"
encoding: "json"
2. Environment Variables
All configuration options can be set via environment variables:
export AXONHUB_SERVER_PORT=8090
export AXONHUB_DB_DIALECT="sqlite3"
export AXONHUB_DB_DSN="file:axonhub.db?cache=shared&_fk=1"
export AXONHUB_LOG_LEVEL="info"
3. Mixed Configuration
Environment variables override YAML configuration values.
Configuration Reference
Server Configuration
server:
port: 8090 # Server port
name: "AxonHub" # Server name
base_path: "" # Base path for API routes
request_timeout: "30s" # Request timeout duration
llm_request_timeout: "600s" # LLM request timeout duration
trace:
thread_header: "AH-Thread-Id" # Thread ID header name
trace_header: "AH-Trace-Id" # Trace ID header name
extra_trace_headers: [] # Extra trace headers
claude_code_trace_enabled: false # Enable Claude Code trace extraction
codex_trace_enabled: false # Enable Codex trace extraction
debug: false # Enable debug mode
Environment Variables:
AXONHUB_SERVER_PORTAXONHUB_SERVER_NAMEAXONHUB_SERVER_BASE_PATHAXONHUB_SERVER_REQUEST_TIMEOUTAXONHUB_SERVER_LLM_REQUEST_TIMEOUTAXONHUB_SERVER_TRACE_THREAD_HEADERAXONHUB_SERVER_TRACE_TRACE_HEADERAXONHUB_SERVER_TRACE_EXTRA_TRACE_HEADERSAXONHUB_SERVER_TRACE_CLAUDE_CODE_TRACE_ENABLEDAXONHUB_SERVER_TRACE_CODEX_TRACE_ENABLEDAXONHUB_SERVER_DEBUG
Database Configuration
db:
dialect: "sqlite3" # sqlite3, postgres, mysql, tidb
dsn: "file:axonhub.db?cache=shared&_fk=1" # Connection string
debug: false # Enable database debug logging
Supported Databases:
- SQLite:
sqlite3(development) - PostgreSQL:
postgres(production) - MySQL:
mysql(production) - TiDB:
tidb(production/cloud)
Environment Variables:
AXONHUB_DB_DIALECTAXONHUB_DB_DSNAXONHUB_DB_DEBUG
Cache Configuration
cache:
mode: "memory" # memory, redis, two-level
# Memory cache configuration
memory:
expiration: "5s" # Memory cache TTL
cleanup_interval: "10m" # Memory cache cleanup interval
# Redis cache configuration
redis:
url: "" # Redis connection URL(redis:// or rediss://)
addr: "" # Redis address: 127.0.0.1:6379
username: "" # Overrides username in URL if set
password: "" # Overrides password in URL if set
db: 0 # Overrides DB in URL path (/0)
tls: false # Enable TLS (also auto-enabled for rediss://)
tls_insecure_skip_verify: false # Skip TLS cert verification (self-signed)
expiration: "30m" # Redis cache TTL
Environment Variables:
AXONHUB_CACHE_MODEAXONHUB_CACHE_MEMORY_EXPIRATIONAXONHUB_CACHE_MEMORY_CLEANUP_INTERVALAXONHUB_CACHE_REDIS_URLAXONHUB_CACHE_REDIS_ADDRAXONHUB_CACHE_REDIS_USERNAMEAXONHUB_CACHE_REDIS_PASSWORDAXONHUB_CACHE_REDIS_DBAXONHUB_CACHE_REDIS_TLSAXONHUB_CACHE_REDIS_TLS_INSECURE_SKIP_VERIFYAXONHUB_CACHE_REDIS_EXPIRATION
Logging Configuration
log:
name: "axonhub" # Logger name
debug: false # Enable debug logging
level: "info" # debug, info, warn, error, panic, fatal
level_key: "level" # Key name for log level field
time_key: "time" # Key name for timestamp field
caller_key: "label" # Key name for caller info field
function_key: "" # Key name for function field
name_key: "logger" # Key name for logger name field
encoding: "json" # json, console, console_json
includes: [] # Logger names to include
excludes: [] # Logger names to exclude
output: "stdio" # file or stdio
file: # File-based logging
path: "logs/axonhub.log" # Log file path
max_size: 100 # Max size in MB before rotation
max_age: 30 # Max age in days to retain
max_backups: 10 # Max number of old log files
local_time: true # Use local time for rotated files
Environment Variables:
AXONHUB_LOG_NAMEAXONHUB_LOG_DEBUGAXONHUB_LOG_LEVELAXONHUB_LOG_LEVEL_KEYAXONHUB_LOG_TIME_KEYAXONHUB_LOG_CALLER_KEYAXONHUB_LOG_FUNCTION_KEYAXONHUB_LOG_NAME_KEYAXONHUB_LOG_ENCODINGAXONHUB_LOG_INCLUDESAXONHUB_LOG_EXCLUDESAXONHUB_LOG_OUTPUTAXONHUB_LOG_FILE_PATHAXONHUB_LOG_FILE_MAX_SIZEAXONHUB_LOG_FILE_MAX_AGEAXONHUB_LOG_FILE_MAX_BACKUPSAXONHUB_LOG_FILE_LOCAL_TIME
Metrics Configuration
metrics:
enabled: false # Enable metrics collection
exporter:
type: "oltphttp" # prometheus, console
endpoint: "localhost:8080" # Metrics exporter endpoint
insecure: true # Enable insecure connection
Environment Variables:
AXONHUB_METRICS_ENABLEDAXONHUB_METRICS_EXPORTER_TYPEAXONHUB_METRICS_EXPORTER_ENDPOINTAXONHUB_METRICS_EXPORTER_INSECURE
Garbage Collection Configuration
gc:
cron: "0 2 * * *" # Cron expression for GC execution
Environment Variables:
AXONHUB_GC_CRON
Provider Quota Configuration
provider_quota:
check_interval: "20m" # Interval for checking provider quota status
Description: This setting controls how frequently AxonHub polls provider API endpoints to check quota status for supported providers (Claude Code, Codex). Quota data is stored in the database and displayed as battery icons in the UI.
Environment Variables:
AXONHUB_PROVIDER_QUOTA_CHECK_INTERVAL
Supported Values:
- Minute intervals that divide evenly into 60:
1m,2m,3m,4m,5m,6m,10m,12m,15m,20m,30m - Hourly intervals:
1h,2h,3h, etc.
Default: 20m
Recommendations:
- Development: Use shorter intervals (e.g.,
5m) to see quota updates quickly - Production: Use
20mor longer to reduce API calls while maintaining reasonable data freshness - Unsupported intervals will be rounded to the nearest supported value with a warning log message
Examples:
provider_quota:
check_interval: "10m" # Check every 10 minutes
export AXONHUB_PROVIDER_QUOTA_CHECK_INTERVAL="30m"
Configuration Examples
Development Configuration
server:
port: 8090
name: "AxonHub Dev"
debug: true
db:
dialect: "sqlite3"
dsn: "file:axonhub.db?cache=shared&_fk=1"
debug: true
log:
level: "debug"
encoding: "console"
output: "stdio"
Production Configuration
server:
port: 8090
name: "AxonHub Production"
debug: false
request_timeout: "30s"
llm_request_timeout: "600s"
db:
dialect: "postgres"
dsn: "postgres://axonhub:password@localhost:5432/axonhub?sslmode=disable"
debug: false
cache:
mode: "redis"
redis:
addr: "redis:6379"
password: "redis-password"
expiration: "30m"
log:
level: "warn"
encoding: "json"
output: "file"
file:
path: "/var/log/axonhub/axonhub.log"
max_size: 200
max_age: 14
max_backups: 7
Database Connection Strings
SQLite
file:axonhub.db?cache=shared&_fk=1
PostgreSQL
postgres://username:password@host:5432/database?sslmode=disable
MySQL
username:password@tcp(host:3306)/database?parseTime=True&multiStatements=true&charset=utf8mb4
Tidb
<USER>.root:<PASSWORD>@tcp(gateway01.us-west-2.prod.aws.tidbcloud.com:4000)/axonhub?tls=true&parseTime=true&multiStatements=true&charset=utf8mb4
Best Practices
Security
Use environment variables for secrets
export AXONHUB_DB_DSN="postgres://axonhub:$(cat /run/secrets/db-password)@localhost:5432/axonhub"Enable TLS for database connections
dsn: "postgres://user:pass@host:5432/axonhub?sslmode=verify-full"Use file-based logging in production
log: output: "file" file: path: "/var/log/axonhub/axonhub.log"
Performance
Use Redis for caching in production
cache: mode: "redis" redis: addr: "redis:6379" expiration: "30m"Configure appropriate timeouts
server: request_timeout: "30s" llm_request_timeout: "600s"Enable metrics for monitoring
metrics: enabled: true exporter: type: "prometheus"
Troubleshooting
Enable debug mode for development
server: debug: true log: level: "debug"Enable data dumping for error analysis
dumper: enabled: true dump_path: "./dumps"
Validation
Validate your configuration:
./axonhub config check
This command will validate your configuration file and report any errors.