env variables configuration #55 #89

Merged
rozetko merged 2 commits from env-variables-configuration-#55 into main 2 years ago
rozetko commented 2 years ago (Migrated from github.com)
Owner

Closes #55

This PR makes it possible to configure hastic using environment variables

Changes:

  • remove config::Environment::with_prefix("HASTIC") usage because it doesn't support nested keys, e.g. alerting.type
  • use update_from_env instead (a function copied from here: f3e5fce6bf/src/config.rs (L132)), it replaces __ in the variables with .

Configuration example:

HASTIC_PORT=8000 \
HASTIC_PROMETHEUS__URL="http://localhost:9090" \
HASTIC_PROMETHEUS__URL="rate(go_memstats_alloc_bytes_total[5m])" \
cargo run

TODO: we also need to add configuration docs to the readme, I'll do it in a separate PR

Closes #55 This PR makes it possible to configure `hastic` using environment variables **Changes**: - remove `config::Environment::with_prefix("HASTIC")` usage because it doesn't support nested keys, e.g. `alerting.type` - use `update_from_env` instead (a function copied from here: https://github.com/rust-lang/mdBook/blob/f3e5fce6bf5e290c713f4015947dc0f0ad172d20/src/config.rs#L132), it replaces `__` in the variables with `.` **Configuration example**: ```bash HASTIC_PORT=8000 \ HASTIC_PROMETHEUS__URL="http://localhost:9090" \ HASTIC_PROMETHEUS__URL="rate(go_memstats_alloc_bytes_total[5m])" \ cargo run ``` **TODO**: we also need to add configuration docs to the readme, I'll do it in a separate PR
glitch4347 commented 2 years ago (Migrated from github.com)
Owner

I've added task for the docs https://github.com/hastic/hastic/issues/90

I've added task for the docs https://github.com/hastic/hastic/issues/90
glitch4347 (Migrated from github.com) reviewed 2 years ago
glitch4347 (Migrated from github.com) commented 2 years ago
Owner
```suggestion ```
glitch4347 (Migrated from github.com) reviewed 2 years ago
glitch4347 (Migrated from github.com) commented 2 years ago
Owner

maybe we should put here 4347

maybe we should put here 4347
glitch4347 (Migrated from github.com) approved these changes 2 years ago

Reviewers

The pull request has been merged as 052e5a5987.
Sign in to join this conversation.
Loading…
There is no content yet.