Skip to content

Commit

Permalink
Update readme for env vars
Browse files Browse the repository at this point in the history
Describe how to supply MQTT username and password via environment variables.
  • Loading branch information
genkobar committed Sep 20, 2021
1 parent c26207f commit 83413b1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,30 @@ metrics:
error_value: 1
```

### Environment Variables

Having the MQTT login details in the config file runs the risk of publishing them to a version control system. To avoid this, you can supply these parameters via environment variables. MQTT2Prometheus will look for `MQTT2PROM_MQTT_USER` and `MQTT2PROM_MQTT_PASSWORD` in the local environment and load them on startup.

#### Example use with Docker

Create a file to store your login details, for example at `~/secrets/mqtt2prom`:
```SHELL
#!/bin/bash
export MQTT2PROM_MQTT_USER="myUser"
export MQTT2PROM_MQTT_PASSWORD="superpassword"
```

Then load that file into the environment before starting the container:
```SHELL
source ~/secrets/mqtt2prom && \
docker run -it \
-e MQTT2PROM_MQTT_USER \
-e MQTT2PROM_MQTT_PASSWORD \
-v "$(pwd)/examples/config.yaml:/config.yaml" \
-p 9641:9641 \
ghcr.io/hikhvar/mqtt2prometheus:latest
```


## Best Practices
The exporter can only listen to one topic_path per instance. If you have to listen to two different topic_paths it is
Expand Down

0 comments on commit 83413b1

Please sign in to comment.