diff --git a/logging.yml b/logging.yml index 1a961b8..9b377d3 100644 --- a/logging.yml +++ b/logging.yml @@ -2,12 +2,15 @@ services: promtail: image: grafana/promtail:${PROMTAIL_VERSION:-2.8.2} + environment: + CHARON_LOKI_ADDRESSES: ${CHARON_LOKI_ADDRESSES} command: -config.file=/etc/promtail/config.yml volumes: - - ./promtail/config.yml:/etc/promtail/config.yml + - ./promtail:/etc/promtail - /var/run/docker.sock:/var/run/docker.sock networks: [dvnode] + entrypoint: /etc/promtail/run.sh restart: unless-stopped networks: - dvnode: \ No newline at end of file + dvnode: diff --git a/promtail/config.yml b/promtail/config.yml.example similarity index 100% rename from promtail/config.yml rename to promtail/config.yml.example diff --git a/promtail/run.sh b/promtail/run.sh new file mode 100755 index 0000000..e5793b9 --- /dev/null +++ b/promtail/run.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ -z "$CHARON_LOKI_ADDRESSES" ]; then + echo "Error: \$CHARON_LOKI_ADDRESSES variable is empty" >&2 + exit 1 +fi + +sed "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \ + /etc/promtail/config.yml.example > /etc/promtail/config.yml + +# Start Promtail with the generated config +/usr/bin/promtail \ + -config.file=/etc/promtail/config.yml