Skip to content

Commit

Permalink
feat: enforce env vars with run.sh to start promtail
Browse files Browse the repository at this point in the history
  • Loading branch information
apham0001 authored and OisinKyne committed Jan 30, 2025
1 parent 04d2113 commit f7d0f82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
dvnode:
File renamed without changes.
13 changes: 13 additions & 0 deletions promtail/run.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7d0f82

Please sign in to comment.