From ed285309551fd6ae88d1391130ba5a7851ffb9ad Mon Sep 17 00:00:00 2001 From: rozetko Date: Thu, 30 Dec 2021 19:12:05 +0300 Subject: [PATCH] readme: initial configuration docs --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index c135a43..c4e1d1f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,42 @@ instance for getting metrics. make ``` +### Configure +Hastic can be configured using config-file or environment variables. + +At first, choose which datasource you'll be using: `prometheus` or `influx`. Only one can be used at a time. + +#### Config-file +- copy the config example to the release directory +```bash +cp config.example.toml release/config.toml +``` +- edit the config file, e.g. using `nano` +```bash +nano release/config.toml +``` + +#### Environment variables +All config fields are also available as environment variables with `HASTIC_` prefix + +Variable name structure: +- for high-level fields: `HASTIC_`, e.g. `HASTIC_PORT` +- for nested fields: `HASTIC___`, e.g. `HASTIC_PROMETHEUS__URL` + +Environment variables can be set either by exporting them (they'll be actual until a bash-session is closed): +```bash +export HASTIC_PORT=8000 +export HASTIC_PROMETHEUS__URL=http://localhost:9090 +export HASTIC_PROMETHEUS__QUERY=rate(go_memstats_alloc_bytes_total[5m]) +``` + +or specifing them in a run command (they'll be actual only for one run) +```bash +HASTIC_PORT=8000 HASTIC_PROMETHEUS__URL=http://localhost:9090 HASTIC_PROMETHEUS__QUERY=rate(go_memstats_alloc_bytes_total[5m]) ./release/hastic +``` + +### Run + ``` cd release ./hastic