126 lines
3.2 KiB
YAML

---
x-logging:
&default-logging
driver: syslog
options:
# This requires two files in /etc/rsyslog.d
# https://www.loggly.com/use-cases/docker-syslog-logging-and-troubleshooting/
tag: "container_name/{{.Name}}"
labels: "${hostname}"
syslog-facility: # cron, local7, etc.
x-opt-values: &volume-opt
driver_opts: &options
type: "nfs"
o: "addr=${IP},rw"
services:
# https://learn.netdata.cloud/docs/agent/packaging/docker
# https://learn.netdata.cloud/docs/agent/exporting/walkthrough
netdata:
image: netdata/netdata
container_name: netdata
hostname: netdata.domain.tld # set to fqdn of host
env_file:
- netdata.env
restart: unless-stopped
cap_add:
- SYS_PTRACE
security_opt:
- apparmor:unconfined
volumes:
- ./netdataconfig:/etc/netdata:rw
- netdatalib:/var/lib/netdata
- netdatacache:/var/cache/netdata
- /etc/passwd:/host/etc/passwd:ro
- /etc/group:/host/etc/group:ro
# - /dev:/host/dev:ro
# - /mnt:/host/mns:ro
# - /var/log:/host/var/log:ro
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /etc/os-release:/host/etc/os-release:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
caddy: ${NETDATA_HOSTNAME}
caddy.log:
caddy.encode: "zstd gzip"
caddy.reverse_proxy: "{{upstreams 19999}}"
caddy.basicauth.{USERNAME}: "hashed_password"
networks:
- netdata
- caddy
- ngp
logging: *default-logging
prometheus:
image: prom/prometheus
container_name: prometheus
hostname: prometheus
# Only if you need to access it locally
# ports:
# - "9090:9090"
env_file:
prometheus.env
volumes:
- prometheus:/etc/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=180d'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
# - '--web.enable-admin-api'
# - '--web.enable-remote-write-receiver'
networks:
- ngp
- caddy
logging: *default-logging
grafana:
image: grafana/grafana
container_name: grafana
restart: unless-stopped
env_file:
grafana.env
volumes:
- grafana:/var/lib/grafana
labels:
caddy: grafana.domain.tld
caddy.log:
caddy.reverse_proxy: "{{upstreams 3000}}"
networks:
- ngp
- caddy
logging: *default-logging
# Can be substituted by a standard volume declaration if it's just a test
# environment or no nfs server is available
volumes:
netdatalib:
<<: *volume-opt
driver_opts:
<<: *options
device: ":/mnt/path/netdata/netdatalib"
netdatacache:
<<: *volume-opt
driver_opts:
<<: *options
device: ":/mnt/path/netdata/netdatacache"
prometheus:
<<: *volume-opt
driver_opts:
<<: *options
device: ":/mnt/path/prometheus/prometheus"
grafana:
<<: *volume-opt
driver_opts:
<<: *options
device: ":/mnt/path/grafana/grafana"
networks:
netdata:
ngp:
caddy:
external: true