Sorry for the late reply.
I followed a great tutorial on youtube by Techno Tim, it explains everything pretty well. It's a bit long, but thorough.
I used this docker-compose file as a base because it connects loki automatically, but you have to add the volumes manually and its not too hard to connect it manually. You can just use the one that Techno Tim uses in the video if you want less complexity in your compose files.
My docker compose file for reference:
version: "3"
services:
loki:
container_name: 'loki'
image: grafana/loki:2.8.0
ports:
- "20110:3100"
command: -config.file=/etc/loki/loki-config.yaml
volumes:
- ./loki:/etc/loki
networks:
- loki
promtail:
image: grafana/promtail:2.8.0
volumes:
- /var/log:/var/log
- ./promtail:/etc/promtail
command: -config.file=/etc/promtail/promtail-config.yaml
networks:
- loki
grafana:
container_name: 'grafana'
image: grafana/grafana-oss:latest
environment:
GF_PATHS_PROVISIONING: /etc/grafana/provisioning
GF_AUTH_ANONYMOUS_ENABLED: false
# GF_LOG_MODE: "console file" #optional, used if you want a log file
# GF_SERVER_ROOT_URL: "(Full url here eg. https://grafana.example.com") #optional, used for redirects
entrypoint:
- sh
- -euc
- |
mkdir -p /etc/grafana/provisioning/datasources
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
apiVersion: 1
datasources:
- name: Loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: true
version: 1
editable: false
EOF
/run.sh
volumes:
- ./grafana/data:/var/lib/grafana
# - ./grafana/logs:/var/log/grafana #log file
ports:
- "20100:3000"
networks:
- loki
networks:
loki:
name: loki
frontend:
external: true
Sorry if the formatting looks bad, since I'm on mobile.
I use frontend as a network that includes containers that connect to nginx proxy manager.
If you have ARM then you might have problems, more info in the comment below
Edit: Better wording
Edit2:typo, edited refrence for clarity and added arm warning