Skip to main content

Configuration

Memtrace is configured via a TOML file and/or environment variables.

Config File

Memtrace looks for memtrace.toml in these locations (in order):

  1. Current directory (./memtrace.toml)
  2. /etc/memtrace/memtrace.toml
  3. $HOME/.memtrace/memtrace.toml

You can also specify a custom config file:

./memtrace -config /path/to/memtrace.toml

Environment Variables

All config values can be overridden with environment variables using the MEMTRACE_ prefix:

MEMTRACE_SERVER_PORT=9100
MEMTRACE_ARC_URL=http://localhost:8000
MEMTRACE_ARC_API_KEY=your_arc_key
MEMTRACE_AUTH_ENABLED=true
MEMTRACE_LOG_LEVEL=debug

Reference

[server]

KeyEnvDefaultDescription
hostMEMTRACE_SERVER_HOST0.0.0.0Bind address
portMEMTRACE_SERVER_PORT9100Listen port
read_timeoutMEMTRACE_SERVER_READ_TIMEOUT30Read timeout (seconds)
write_timeoutMEMTRACE_SERVER_WRITE_TIMEOUT30Write timeout (seconds)
shutdown_timeoutMEMTRACE_SERVER_SHUTDOWN_TIMEOUT30Graceful shutdown timeout (seconds)

[log]

KeyEnvDefaultDescription
levelMEMTRACE_LOG_LEVELinfoLog level (debug, info, warn, error)
formatMEMTRACE_LOG_FORMATconsoleLog format (console or json)

[arc]

KeyEnvDefaultDescription
urlMEMTRACE_ARC_URLhttp://localhost:8000Arc instance URL
api_keyMEMTRACE_ARC_API_KEYArc API key
databaseMEMTRACE_ARC_DATABASEmemoryArc database name
measurementMEMTRACE_ARC_MEASUREMENTeventsArc measurement name
connect_timeoutMEMTRACE_ARC_CONNECT_TIMEOUT5Connection timeout (seconds)
query_timeoutMEMTRACE_ARC_QUERY_TIMEOUT30Query timeout (seconds)
write_batch_sizeMEMTRACE_ARC_WRITE_BATCH_SIZE100Records per write batch
write_flush_interval_msMEMTRACE_ARC_WRITE_FLUSH_INTERVAL_MS1000Flush interval (milliseconds)

[auth]

KeyEnvDefaultDescription
enabledMEMTRACE_AUTH_ENABLEDtrueEnable API key authentication
db_pathMEMTRACE_AUTH_DB_PATH./data/memtrace.dbSQLite database path

[dedup]

KeyEnvDefaultDescription
enabledMEMTRACE_DEDUP_ENABLEDtrueEnable deduplication
window_hoursMEMTRACE_DEDUP_WINDOW_HOURS24Dedup time window (hours)

Example Configuration

# Memtrace Configuration
# https://memtrace.ai

[server]
host = "0.0.0.0"
port = 9100

[log]
level = "info"
format = "json" # Use "json" in production

[arc]
url = "http://localhost:8000"
api_key = "your_arc_api_key"
database = "memory"
measurement = "events"
write_batch_size = 100
write_flush_interval_ms = 1000

[auth]
enabled = true
db_path = "./data/memtrace.db"

[dedup]
enabled = true
window_hours = 24

Docker Configuration

When running in Docker, use environment variables:

docker run -p 9100:9100 \
-e MEMTRACE_ARC_URL=http://host.docker.internal:8000 \
-e MEMTRACE_ARC_API_KEY=your_arc_key \
-e MEMTRACE_LOG_LEVEL=info \
-e MEMTRACE_LOG_FORMAT=json \
-v ./data:/app/data \
basekicklabs/memtrace:latest

Or mount a custom config file:

docker run -p 9100:9100 \
-v ./memtrace.toml:/etc/memtrace/memtrace.toml \
-v ./data:/app/data \
basekicklabs/memtrace:latest

Configuration Notes

Arc Connection

  • arc.url: Point to your Arc instance. Use host.docker.internal when running Memtrace in Docker and Arc on the host.
  • arc.api_key: Optional if Arc has auth disabled.
  • arc.database: The Arc database where memories are stored. Created automatically if it doesn't exist.
  • arc.measurement: The Arc measurement (table) for memory events. Created automatically.

Write Batching

Memtrace batches writes to Arc for performance:

  • write_batch_size: Number of records per batch (default 100)
  • write_flush_interval_ms: Max time to wait before flushing a partial batch (default 1000ms)

Increase batch size for higher throughput. Decrease flush interval for lower latency.

Deduplication

Memtrace can deduplicate memories within a time window:

  • dedup.enabled: Enable/disable deduplication
  • dedup.window_hours: Time window to check for duplicates (default 24 hours)

Deduplication uses the dedup_key field. If two memories have the same dedup_key within the window, the second is rejected.

Authentication

  • auth.enabled: Enable API key authentication (recommended for production)
  • auth.db_path: SQLite database path for storing API keys

On first run with auth enabled, Memtrace generates an admin API key and prints it to the console. Save this key — it's shown only once.

To disable auth (not recommended for production):

[auth]
enabled = false

Logging

  • log.level: debug, info, warn, error
  • log.format: console (human-readable) or json (structured)

Use json format in production for log aggregation tools.