.env.example to .env and configure the variables below for your environment.
Loading environment variables
Watchdog uses thegodotenv package to load environment variables from a .env file at startup. The env package provides helper functions to fetch typed values:
If a required environment variable is missing and no fallback is provided, the application will panic at startup with a clear error message.
Application environment
Application environment identifier. Controls environment-specific behavior and logging.Common values:
dev- Development environmentstaging- Staging environmentprod- Production environment
Redis configuration
Watchdog uses Redis for interval list caching and worker coordination.Redis server host and port in the format
host:port.Example: 127.0.0.1:6379 or redis.example.com:6379Redis server password. Leave empty if Redis doesn’t require authentication.
Redis database index (0-15). Allows isolating Watchdog data from other applications.Example:
2Worker and pool configuration
These settings control the concurrency and performance characteristics of the monitoring system.Maximum number of child workers spawned per parent worker group.Each child worker performs actual HTTP checks. Higher values increase concurrency but consume more resources.Recommended range:
3-10 depending on server capacityTotal work pool size controlling how many URLs are processed concurrently per batch.This value determines the batch size when processing URLs at each monitoring interval.Recommended range:
20-100 depending on server capacity and target countTimeout in seconds for HTTP requests performed by child workers.If a monitored URL doesn’t respond within this timeframe, the check is marked as failed.Recommended range:
5-30 secondsTimeout in seconds for supervisor batch flushing operations.The supervisor batches check results before processing. This controls how long to wait before flushing accumulated results.Recommended range:
3-10 secondsBatch size for supervisor flush operations.The supervisor processes check results in batches to improve efficiency. Higher values reduce overhead but increase memory usage.Recommended range:
50-200Database configuration
See Database configuration for detailed PostgreSQL/TimescaleDB setup.PostgreSQL username for database connections.Example:
tsdbadmin or watchdog_userPostgreSQL password for the database user.
PostgreSQL server hostname or IP address.Examples:
localhost- Local databasepostgres.example.com- Remote database10.0.1.5- IP address
PostgreSQL server port number.Default PostgreSQL port is
5432.PostgreSQL database name.This database must exist and have the TimescaleDB extension installed.
Migration configuration
Watchdog uses Goose for database migrations.Goose database driver name.For PostgreSQL/TimescaleDB, use
postgres.Database connection string used by Goose for migrations.Typically interpolates the
DB_* variables:For production, replace
sslmode=disable with sslmode=require to enforce SSL/TLS connections.Path to the directory containing migration files.Relative to the project root. Default is
migrations.Email configuration
See Email configuration for detailed SMTP setup.Sender email address used for notification emails.This address appears in the “From” field of status change notifications.Example:
[email protected]SMTP server hostname.Examples:
sandbox.smtp.mailtrap.io- Mailtrap (development)smtp.gmail.com- Gmailsmtp.sendgrid.net- SendGrid
SMTP server port number.Common ports:
25- Standard SMTP (often blocked by ISPs)587- SMTP with STARTTLS (recommended)465- SMTP over SSL2525- Alternative port (Mailtrap)
SMTP authentication username.Required by most SMTP providers for authentication.
SMTP authentication password or API key.
Example configuration
Complete .env.example file
Complete .env.example file
.env.example
Validation and error handling
Watchdog validates required environment variables at startup:Load .env file
The application attempts to load environment variables from the
.env file using godotenv.Load().If the file is missing, the application will panic with “Error loading file”.Fetch required variables
Each required variable is fetched using
env.FetchString() or env.FetchInt().If a required variable is missing and no fallback is provided, the application panics with the variable name.The panic-on-error approach ensures that configuration issues are caught immediately at startup rather than causing runtime failures.