Configuration#
Dynaconf is used to configure the system. Its pros are:
it handles multiple environments,
it handles host-specific settings & secrets
both global and per-environment defaults can be provided
configuration can be sourced from environment variables as well
TOML is simple and straightforward to read and write
The configuration directory defaults to the conf
directory in the current working
directory where the command is invoked. Both the directory and the environment used
(dev
by default) can be overriden on the command-line with the config-dir
and
env
options respectivelly. The site specs can be inlined in the TOML config, or
provided using a separate YAML file passed with the site-specs-file
option in
the CLI.
The file settings.toml
provided in the conf
directory should work out of the box
with docker compose.
Secrets can be defined in a .secrets.toml
file in the same directory or passed using
environment variables. Envvars have the advantage of being able to be set by external programs.
Any additional configuration is merged in the global
configuration, superseding it. The file .secrets.sample.toml
shows an example of how
to set a postgres password for the prod
environment.
The configuration file has a section per environment. Each environment may define the
following sub-sections: kafka
, postgres
, sentry
, server
.
Settings file#
General config#
Parameter |
Default Value |
Description |
---|---|---|
|
|
Relative or absolute path to TLS certs dir. Defaults to the ‘certs’ sub-directory in working directory. |
|
|
Relative or absolute path to logging directory. Will attempt to create it if it does not exist |
|
|
Default log level. |
|
|
The name of the Kafka topic where to send the metrics to. |
|
|
File name with monitor specs |
|
|
The default scraping freqency is milliseconds (can be adjusted per-site). |
Kafka#
Parameter |
Default Value |
Description |
---|---|---|
|
|
The URI to the Kafka servers where to publish and consume messages. |
|
|
Type of compression to be used by rest proxy producers |
|
|
Level of consistency desired by each producer message sent on the rest proxy. More on Kafka Producer |
|
|
Time to wait for grouping together requests. More on Kafka Producer |
|
Empty for dev and test. |
The path to the SSL CA certificate. |
|
Empty for dev and test. |
The path to the SSL certfile. |
|
Empty for dev and test. |
The path to the SSL keyfile. |
Postgres#
Parameter |
Default Value |
Description |
---|---|---|
|
|
DB user |
|
|
DB name |
|
|
DB password |
|
|
Server hostname |
|
|
Server port |
Sentry#
All keys and values will be passed to the Sentry SDK as-is. The only required value is
the DSN
. Setting the environment variable SENTRY_DSN
will also enable sentry
integration. See the configuration options in the Sentry docs.
Server#
The server is based on aiohttp.
Parameter |
Default Value |
Description |
---|---|---|
|
|
Listening host for the server. Use an empty string to listen to all available networks. |
|
|
Listening port for the server. |
Sites#
The monitoring spec for each site has three keys: url
(required), regexp
and
frequency_ms
(optional). Here is an example using all three. The regular expressions
are compiled by the Python standard library’s re.compile()
.
- url: https://status.aiven.io/
regexp: "All Systems Operational"
- url: https://status.twilio.com/
regexp: "INCIDENTS REPORTED"
frequency_ms: 300000
- url: https://health.aws.amazon.com/health/status
regexp: "No incidents reported today."
Environment variables#
Variables prefixed with WMS
are parsed according to the settings files structure
detailed below. For instance, WMS_kafka__bootstrap_servers
sets the value for the
bootstrap_servers
variable of the kafka
section.
See the Dynaconf documentation for more details,
and scripts/export-tf-outputs.sh
for a usage example.
Importantly, the environment can be set by the WMS_ENV
variable. The two following
commands are equivalent:
wms -e prod app
WMS_ENV=prod wms app
CLI arguments#
Some options can be passed on the CLI, overriding both configuration files and environment variables.
Options:
-c, --config-dir DIRECTORY Config dir (default: 'conf' sub-directory)
-e, --env TEXT Runtime environment (default: set in `WMS_ENV`,
or `dev` otherwise)
-s, --spec-file FILE Sites specs file path
-h, --host TEXT Server host (default: localhost)
-p, --port INTEGER Server port (default: 8080)
--debug / --no-debug Force debug logging