Skip to main content

Environment Variables

This page documents all environment variables available in Anomstack. Copy the .example.env file to .env and configure the variables you need.

cp .example.env .env

🗄️ Database & Data Sources

Google Cloud Platform

Configure access to BigQuery and Google Cloud Storage.

VariableRequiredDescriptionExample
ANOMSTACK_GOOGLE_APPLICATION_CREDENTIALSNoPath to GCP service account JSON file/path/to/credentials.json
ANOMSTACK_GOOGLE_APPLICATION_CREDENTIALS_JSONNoGCP credentials as JSON string (alternative to file path){"type": "service_account", ...}
ANOMSTACK_GCP_PROJECT_IDNoGoogle Cloud Project ID for BigQuerymy-project-123

Snowflake

Connect to Snowflake data warehouse.

VariableRequiredDescriptionExample
ANOMSTACK_SNOWFLAKE_ACCOUNTNoSnowflake account identifierxy12345.us-east-1
ANOMSTACK_SNOWFLAKE_USERNoSnowflake usernameanomstack_user
ANOMSTACK_SNOWFLAKE_PASSWORDNoSnowflake passwordyour-password
ANOMSTACK_SNOWFLAKE_WAREHOUSENoSnowflake warehouse nameANOMSTACK_WH

AWS

Connect to S3 and other AWS services.

VariableRequiredDescriptionExample
ANOMSTACK_AWS_ACCESS_KEY_IDNoAWS access key IDAKIAIOSFODNN7EXAMPLE
ANOMSTACK_AWS_SECRET_ACCESS_KEYNoAWS secret access keywJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

ClickHouse

Connect to ClickHouse database.

VariableRequiredDescriptionDefaultExample
ANOMSTACK_CLICKHOUSE_HOSTNoClickHouse hostlocalhostclickhouse.example.com
ANOMSTACK_CLICKHOUSE_PORTNoClickHouse port81238123
ANOMSTACK_CLICKHOUSE_USERNoClickHouse usernameanomstackadmin
ANOMSTACK_CLICKHOUSE_PASSWORDNoClickHouse passwordanomstackyour-password
ANOMSTACK_CLICKHOUSE_DATABASENoClickHouse databasedefaultmetrics

MotherDuck & Turso

Enhanced DuckDB and SQLite services.

VariableRequiredDescriptionExample
ANOMSTACK_MOTHERDUCK_TOKENNoMotherDuck authentication tokenyour-motherduck-token
ANOMSTACK_TURSO_DATABASE_URLNoTurso database URLlibsql://your-db.turso.io
ANOMSTACK_TURSO_AUTH_TOKENNoTurso authentication tokenyour-turso-token

💾 Storage Configuration

Database Paths

Configure where metrics and metadata are stored.

VariableRequiredDescriptionDocker DefaultLocal Default
ANOMSTACK_DUCKDB_PATHNoDuckDB database path/data/anomstack.dbtmpdata/anomstack-duckdb.db
ANOMSTACK_SQLITE_PATHNoSQLite database pathtmpdata/anomstack-sqlite.dbtmpdata/anomstack-sqlite.db
ANOMSTACK_TABLE_KEYNoTable identifier for metricstmp.metricsproduction.metrics

Model Storage

Configure where trained ML models are stored.

VariableRequiredDescriptionExamples
ANOMSTACK_MODEL_PATHNoModel storage locationlocal://./tmp/models
gs://your-bucket/models
s3://your-bucket/models

Storage Options:

  • Local: local://./tmp/models (default)
  • Google Cloud Storage: gs://your-bucket/models
  • AWS S3: s3://your-bucket/models

Application Paths

Internal directory configuration.

VariableRequiredDescriptionDefault
ANOMSTACK_HOMENoHome directory for Anomstack. (current directory)

📧 Alert Configuration

Email Alerts

Configure email notifications for anomalies.

VariableRequiredDescriptionDefaultExample
ANOMSTACK_ALERT_EMAIL_FROMNoSender email addressalerts@yourcompany.com
ANOMSTACK_ALERT_EMAIL_TONoRecipient email addressteam@yourcompany.com
ANOMSTACK_ALERT_EMAIL_SMTP_HOSTNoSMTP server hostsmtp.gmail.comsmtp.office365.com
ANOMSTACK_ALERT_EMAIL_SMTP_PORTNoSMTP server port58725
ANOMSTACK_ALERT_EMAIL_PASSWORDNoEmail password/app tokenyour-app-password

Failure Email Alerts

Separate email configuration for job failures.

VariableRequiredDescriptionExample
ANOMSTACK_FAILURE_EMAIL_FROMNoSender for failure alertsfailures@yourcompany.com
ANOMSTACK_FAILURE_EMAIL_TONoRecipient for failure alertsops@yourcompany.com
ANOMSTACK_FAILURE_EMAIL_SMTP_HOSTNoSMTP host for failuressmtp.gmail.com
ANOMSTACK_FAILURE_EMAIL_SMTP_PORTNoSMTP port for failures587
ANOMSTACK_FAILURE_EMAIL_PASSWORDNoEmail password for failuresyour-app-password

Slack Alerts

Configure Slack notifications.

VariableRequiredDescriptionExample
ANOMSTACK_SLACK_BOT_TOKENNoSlack bot tokenxoxb-your-bot-token
ANOMSTACK_SLACK_CHANNELNoSlack channel for alerts#anomaly-alerts

🤖 LLM Integration

OpenAI

Configure AI-powered anomaly detection and alerts.

VariableRequiredDescriptionDefaultExample
ANOMSTACK_OPENAI_KEYNoOpenAI API keysk-...
OPENAI_API_KEYNoAlternative OpenAI API keysk-...
ANOMSTACK_OPENAI_MODELNoOpenAI model to usegpt-4o-minigpt-4o

Anthropic

Alternative LLM provider.

VariableRequiredDescriptionDefaultExample
ANOMSTACK_ANTHROPIC_KEYNoAnthropic API keysk-ant-...
ANOMSTACK_ANTHROPIC_MODELNoAnthropic modelclaude-3-haiku-20240307claude-3-sonnet-20240229

LLM Platform Selection

VariableRequiredDescriptionDefaultOptions
ANOMSTACK_LLM_PLATFORMNoWhich LLM provider to useopenaiopenai, anthropic

LangSmith Tracing

Optional LLM call tracing and monitoring.

VariableRequiredDescriptionDefaultExample
LANGSMITH_TRACINGNoEnable LangSmith tracingtruefalse
LANGSMITH_ENDPOINTNoLangSmith API endpointhttps://api.smith.langchain.com
LANGSMITH_API_KEYNoLangSmith API keyyour-api-key
LANGSMITH_PROJECTNoLangSmith project nameanomaly-agentyour-project

⚙️ Dagster Configuration

Core Dagster Settings

VariableRequiredDescriptionDefaultExample
DAGSTER_LOG_LEVELNoDagster logging levelDEBUGINFO, WARNING, ERROR
DAGSTER_CONCURRENCYNoNumber of concurrent jobs48

Dagster Directories

Lightweight defaults to prevent disk space issues.

VariableRequiredDescriptionDefault
ANOMSTACK_DAGSTER_LOCAL_ARTIFACT_STORAGE_DIRNoArtifacts storage directorytmp_light/artifacts
ANOMSTACK_DAGSTER_OVERALL_CONCURRENCY_LIMITNoOverall concurrency limit5
ANOMSTACK_DAGSTER_DEQUEUE_USE_THREADSNoUse threads for dequeuingfalse
ANOMSTACK_DAGSTER_DEQUEUE_NUM_WORKERSNoNumber of dequeue workers2
ANOMSTACK_DAGSTER_LOCAL_COMPUTE_LOG_MANAGER_DIRECTORYNoCompute logs directorytmp_light/compute_logs
ANOMSTACK_DAGSTER_SQLITE_STORAGE_BASE_DIRNoSQLite storage base directorytmp_light/storage

Job Timeout Configuration

VariableRequiredDescriptionDefaultExample
ANOMSTACK_MAX_RUNTIME_SECONDS_TAGNoMax job runtime in seconds9001800
ANOMSTACK_KILL_RUN_AFTER_MINUTESNoKill long-running jobs after N minutes1530

🐳 Docker & Deployment

PostgreSQL (Docker)

Database for Dagster metadata when using Docker.

VariableRequiredDescriptionDefault
ANOMSTACK_POSTGRES_USERNoPostgreSQL usernamepostgres_user
ANOMSTACK_POSTGRES_PASSWORDNoPostgreSQL passwordpostgres_password
ANOMSTACK_POSTGRES_DBNoPostgreSQL database namepostgres_db
ANOMSTACK_POSTGRES_FORWARD_PORTNoLocal port forwarding5432 (leave blank to disable)

Dashboard Configuration

VariableRequiredDescriptionDefault
ANOMSTACK_DASHBOARD_PORTNoDashboard port5001

🔧 Advanced Configuration

Example Metrics

VariableRequiredDescriptionDefaultOptions
ANOMSTACK_IGNORE_EXAMPLESNoIgnore example metricsnoyes, no

Auto-Reload Configuration

Automatically reload configuration when files change.

VariableRequiredDescriptionDefaultExample
ANOMSTACK_AUTO_CONFIG_RELOADNoEnable scheduled config reloadfalsetrue
ANOMSTACK_CONFIG_RELOAD_CRONNoConfig reload schedule*/5 * * * **/10 * * * *
ANOMSTACK_CONFIG_RELOAD_STATUSNoConfig reload job statusSTOPPEDRUNNING
ANOMSTACK_CONFIG_WATCHERNoEnable smart file watchertruefalse
ANOMSTACK_CONFIG_WATCHER_INTERVALNoFile watcher check interval (seconds)3060

Analytics

VariableRequiredDescriptionExample
POSTHOG_API_KEYNoPostHog analytics API keyphc_...

🎛️ Per-Metric Batch Overrides

You can override any configuration parameter for specific metric batches using environment variables:

ANOMSTACK__<METRIC_BATCH>__<PARAMETER>=<VALUE>

Format Rules:

  • <METRIC_BATCH>: Uppercase metric batch name with dashes replaced by underscores
  • <PARAMETER>: Uppercase parameter name with underscores

Examples:

# Override database for python_ingest_simple metric batch
ANOMSTACK__PYTHON_INGEST_SIMPLE__DB=bigquery

# Override alert methods
ANOMSTACK__PYTHON_INGEST_SIMPLE__ALERT_METHODS=email

# Override schedule
ANOMSTACK__PYTHON_INGEST_SIMPLE__INGEST_CRON_SCHEDULE="*/1 * * * *"

# Enable specific job schedules
ANOMSTACK__PYTHON_INGEST_SIMPLE__INGEST_DEFAULT_SCHEDULE_STATUS=RUNNING
ANOMSTACK__PYTHON_INGEST_SIMPLE__TRAIN_DEFAULT_SCHEDULE_STATUS=RUNNING
ANOMSTACK__PYTHON_INGEST_SIMPLE__SCORE_DEFAULT_SCHEDULE_STATUS=RUNNING
ANOMSTACK__PYTHON_INGEST_SIMPLE__ALERT_DEFAULT_SCHEDULE_STATUS=RUNNING

This allows you to configure different metric batches differently without modifying YAML files.

📝 Common Configuration Patterns

Development Setup

# Use local storage
ANOMSTACK_DUCKDB_PATH=tmpdata/anomstack-duckdb.db
ANOMSTACK_MODEL_PATH=local://./tmp/models
ANOMSTACK_IGNORE_EXAMPLES=no

# Basic email alerts
ANOMSTACK_ALERT_EMAIL_FROM=dev@company.com
ANOMSTACK_ALERT_EMAIL_TO=developer@company.com

Production Setup

# Use cloud storage
ANOMSTACK_MODEL_PATH=gs://company-anomstack/models
ANOMSTACK_DUCKDB_PATH=/data/anomstack.db

# Production alerts
ANOMSTACK_ALERT_EMAIL_FROM=alerts@company.com
ANOMSTACK_ALERT_EMAIL_TO=ops-team@company.com
ANOMSTACK_SLACK_CHANNEL=#production-alerts

# Disable examples
ANOMSTACK_IGNORE_EXAMPLES=yes

BigQuery + GCS Setup

# BigQuery connection
ANOMSTACK_GCP_PROJECT_ID=your-project-id
ANOMSTACK_GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json

# Use GCS for model storage
ANOMSTACK_MODEL_PATH=gs://your-bucket/models

# BigQuery table for metrics
ANOMSTACK_TABLE_KEY=your_dataset.metrics

🔐 Security Best Practices

  1. Use environment files: Never commit .env files with secrets to version control
  2. Rotate credentials: Regularly rotate API keys and passwords
  3. Least privilege: Use service accounts with minimal required permissions
  4. Secrets management: Consider using proper secrets management in production (AWS Secrets Manager, Google Secret Manager, etc.)
  5. File permissions: Restrict access to your .env file (chmod 600 .env)

🆘 Troubleshooting

Environment not loading?

  • Ensure .env file exists in the project root
  • Check file permissions and syntax
  • Verify no extra spaces around = signs

Docker not picking up changes?

  • Restart containers: make docker-stop && make docker
  • Check if environment is properly mounted

Database connection issues?

  • Verify credentials and network access
  • Test connections independently
  • Check firewall and VPN settings