Skip to main content

Configuring

note

The easiest way to get started with Swetrix is by using our cloud service. We do all the dirty work for you: hosting, maintenance, backups, worldwide CDN, etc. Using Cloud you still own the data, you can export it or delete it at any time you want. By using Swetrix Cloud you support maintenance and development of the product, which eventually makes it better.

The following environment variables are available for configuration:

Frontend (swetrix image)

VariableDefaultDescription
API_URLhttp://localhost:8080/URL of the self-hosted Swetrix API instance. Swetrix frontend will use this variable to connect to the API, so make sure it's correct.
caution

Swetrix Community Edition is split into two containers: swetrix (frontend - the frontend web UI) and swetrix-api (backend - the API server, that does auth, data logging, etc.). The API_URL variable on the frontend container must point to the backend container, which by default is http://localhost:8080/.

So if you're self-hosting on subdomains, you might run swetrix.mydomain.com proxied to port 80 for the frontend user interface (where you log in), and swetrix-api.mydomain.com proxied to port 8080, and set API_URL=https://swetrix-api.mydomain.com.

This is the most common issue users encounter when self-hosting Swetrix Community Edition, so please make sure to set it correctly.

Backend (swetrix-api image)

Basic configuration

VariableDefaultDescription
SECRET_KEY_BASEauto-generated by configure.shSecret used for auth keys and login sessions. Must be set.
CLOUDFLARE_PROXY_ENABLEDfalseIf set to true - Swetrix will get IP address information from cf-connecting-ip header provided by Cloudflare.
IS_PRIMARY_NODEtrueYou should not touch this variable unless you know what you are doing. It's used to spin off multiple API instances in a cluster, where only one of them will be primary. If changed to false, things like cron task manager will be disabled for this instance.

Email configuration (SMTP)

Swetrix will send transactional emails for some actions, like password reset or project invitations. You must configure SMTP credentials for this to work correctly.

VariableDefaultDescription
SMTP_HOSTSMTP host
SMTP_PORTSMTP port
SMTP_USERSMTP user (if your SMTP provider requires authentication)
SMTP_PASSWORDSMTP password (if your SMTP provider requires authentication)
FROM_EMAILEmail address to use for sending emails
SMTP_MOCKfalseIf set to true - emails will not be sent, but will be logged to the console instead

If you don't have an SMTP provider, some regular email providers offer this functionality. For example, you can configure Gmail for app specific passwords and use them as SMTP credentials (in this case, the SMTP_HOST should be smtp.gmail.com with port 587).

OIDC configuration

Swetrix Community Edition also supports OIDC authentication. To enable it, you need to set the following variables:

VariableDefaultDescription
OIDC_ENABLEDfalseMust be set to true to enable OIDC authentication.
OIDC_ONLY_AUTHfalseIf set to true - Swetrix will only allow users to authenticate via OIDC (i.e. regular login / registration form will not work).
OIDC_DISCOVERY_URLURL of the OIDC discovery endpoint, for example https://example.com/.well-known/openid-configuration
OIDC_CLIENT_IDOIDC client ID
OIDC_CLIENT_SECRETOIDC client secret

Redis

VariableDefaultDescription
REDIS_PASSWORDpasswordRedis password
REDIS_PORT6379Redis port
REDIS_USERdefaultRedis user

Clickhouse

VariableDefaultDescription
CLICKHOUSE_DATABASEanalyticsClickHouse database
CLICKHOUSE_USERdefaultClickHouse user
CLICKHOUSE_PORT8123ClickHouse port
CLICKHOUSE_PASSWORDClickHouse password

Help us improve Swetrix

Was this page helpful to you?