Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ RUN chmod a+x *.sh
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

CMD ["/mqtt-logger/start.sh"]

ENV MQTT_LOGGER_LOKI_CLIENT_URL=http://loki:3100/loki/api/v1/push MQTT_LOGGER_LOKI_TENANT_ID=test MQTT_LOGGER_MQTT_HOSTNAME=mqtt MQTT_LOGGER_MQTT_PORT=1883 MQTT_LOGGER_MQTT_TOPICS="+/debug homeassistant/#"
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ positions:
filename: /opt/mqtt_promtail/positions.yaml
clients:
- url: ${MQTT_LOGGER_LOKI_CLIENT_URL}
tenant_id: ${MQTT_LOGGER_LOKI_TENANT_ID}
scrape_configs:
- job_name: mqtt_logger
pipeline_stages:
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ services:
container_name: mqtt-logger
environment:
MQTT_LOGGER_HOST_HOSTNAME: <hostname>
MQTT_LOGGER_LOKI_CLIENT_URL: http://log01.tylephony.com:3100/loki/api/v1/push
MQTT_LOGGER_LOKI_CLIENT_URL: http://loki:3100/loki/api/v1/push
MQTT_LOGGER_LOKI_TENANT_ID: <tenant>
MQTT_LOGGER_MQTT_HOSTNAME: <hostname>
MQTT_LOGGER_MQTT_PASSWORD: <password>
MQTT_LOGGER_MQTT_PORT: 1883
MQTT_LOGGER_MQTT_USERNAME: <username>
MQTT_LOGGER_MQTT_TOPICS: '+/debug homeassistant/#'
TZ: America/Chicago
image: lux4rd0/mqtt_logger:latest
restart: always
Expand Down
4 changes: 2 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mosquitto_sub -h $MQTT_LOGGER_MQTT_HOSTNAME -p $MQTT_LOGGER_MQTT_PORT -u $MQTT_LOGGER_MQTT_USERNAME -P $MQTT_LOGGER_MQTT_PASSWORD -F %j -t '+/debug' -t 'homeassistant/#' | promtail --stdin --config.expand-env=true --config.file=/mqtt-logger/config.yaml

for item in $MQTT_LOGGER_MQTT_TOPICS; do mqtt_topics="${mqtt_topics} -t $item"; done
mosquitto_sub -h $MQTT_LOGGER_MQTT_HOSTNAME -p $MQTT_LOGGER_MQTT_PORT -u $MQTT_LOGGER_MQTT_USERNAME -P $MQTT_LOGGER_MQTT_PASSWORD -F %j $mqtt_topics | promtail --stdin --config.expand-env=true --config.file=/mqtt-logger/config.yaml