Skip to content

Commit

Permalink
add grafana loki logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Bladesheng committed Nov 5, 2023
1 parent 5b97ab3 commit acfdea1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ VAPID_PRIVATE_KEY="privateKey"

# https://github.com/Bladesheng/weather-station-db-backup3/blob/main/.example.env
GDRIVE_FOLDER_ID="xxx"

# get this from grafana Home > Connections > Add new connection > Hosted logs
# https://grafana.com/docs/loki/latest/send-data/docker-driver/configuration/
LOKI_URL="https://123456:[email protected]/api/prom/push"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The production docker-compose just glues all the images together, so that the on

- Clone the repo, then create `.env` file - see [`.env.example`](https://github.com/Bladesheng/weather-station-backend/blob/main/.env.example)

- Install [Grafana Loki Docker driver client](https://grafana.com/docs/loki/latest/send-data/docker-driver/) for logs storage

- Get Google service account JSON key and place it in the same folder as docker-compose - same as [here](https://github.com/weather-blade/weather-db-backup)

- Install packages:
Expand Down
20 changes: 20 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ services:
redis:
image: redis:7.2.2-bookworm
restart: unless-stopped
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

db:
image: postgres:15.2
Expand All @@ -12,6 +16,10 @@ services:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

db-backup:
# https://github.com/weather-blade/weather-db-backup
Expand All @@ -24,6 +32,10 @@ services:
GDRIVE_FOLDER_ID: ${GDRIVE_FOLDER_ID}
volumes:
- ./SA_key.json:/app/SA_key.json:ro
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

notifications:
# https://github.com/weather-blade/weather-notifications
Expand All @@ -35,6 +47,10 @@ services:
DATABASE_URL: ${DATABASE_URL}
VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY}
VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY}
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

server:
build: .
Expand All @@ -54,6 +70,10 @@ services:
DATABASE_URL: ${DATABASE_URL}
VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY}
VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY}
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

volumes:
db-data:
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ services:
redis:
image: redis:7.2.2-bookworm
restart: unless-stopped
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

db:
image: postgres:15.2
Expand All @@ -12,6 +16,10 @@ services:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

db-backup:
# https://github.com/weather-blade/weather-db-backup
Expand All @@ -24,6 +32,10 @@ services:
GDRIVE_FOLDER_ID: ${GDRIVE_FOLDER_ID}
volumes:
- ./SA_key.json:/app/SA_key.json:ro
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

notifications:
# https://github.com/weather-blade/weather-notifications
Expand All @@ -35,6 +47,10 @@ services:
DATABASE_URL: ${DATABASE_URL}
VAPID_PRIVATE_KEY: ${VAPID_PRIVATE_KEY}
VAPID_PUBLIC_KEY: ${VAPID_PUBLIC_KEY}
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

server:
image: ghcr.io/weather-blade/weather-server:latest
Expand All @@ -56,6 +72,10 @@ services:
networks:
- 'nginx_proxy_net'
- 'default'
logging:
driver: loki
options:
loki-url: ${LOKI_URL}

volumes:
db-data:
Expand Down

0 comments on commit acfdea1

Please sign in to comment.