i have docker swarm with traefik on front, i want to add some monitoring with grafana to…
- User
i have docker swarm with traefik on front, i want to add some monitoring with grafana to monitor all containers, cpu usage, network etc, web app availabilities. how to do that?
- Assistant
- User
do i need to define docker networks somehow?
- Assistant
- User
what if all my containers already using traefik-public network
- Assistant
- User
do i need to add something to each containers' docker-compose?
- Assistant
- User
okay, could you provide resulting docker-compose.yml with monitoring setup into swarm. alongside with all needed config files
- Assistant
- User
set up Prometheus as a data source.
- Prometheus: If you’ve exposed the port, access it via http://<your-swarm-manager-node>:9090. i do not add it as exposed, how to set it up?
- Assistant
If you have not exposed Prometheus on an external port and it is only accessible from within the Docker Swarm network, you can still set it up as a data source in Grafana by using the internal network and service name. Here’s how to do it:
Steps to Set Up Prometheus as a Data Source in Grafana
-
Access Grafana:
- Ensure your Grafana service is accessible from your local network or through a port-forwarding setup. Open a web browser and navigate to .
-
- User
F0823 07:32:25.794669 1 cadvisor.go:146] Failed to create a Container Manager: mountpoint for cpu not found
- Assistant
- User
cgroup2 /sys/fs/cgroup cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
- Assistant
- User
why do i need cadvisor?
- Assistant
- User
okay, it is working after upgrade. thanks. now something different - i've got many errors in traefik logs:
2024-08-23T07:48:06Z ERR error="service "portainer-agent-pazo5dd2lwowxdfl4vnujzz44-ieib59acm49wo2a5hangzpw5n" error: port is missing" container=portainer-agent-pazo5dd2lwowxdfl4vnujzz44-ieib59acm49wo2a5hangzpw5n-2307fcb46c1fb92b5300ac79a9121bbb44e10720aa8f424e6204b57bb374a745 providerName=docker
- Assistant
- User
i do not have any of this, where is it should be? i have this
services: portainer: image: portainer/portainer-ce volumes: - portainer_data:/data networks: - traefik-public ports: - "9000:9000" deploy: replicas: 1 restart_policy: condition: on-failure labels: - "traefik.enable=true" - "traefik.http.routers.portainer-https.rule=Host(
portainer.dev.zverinec.media)" - "traefik.http.routers.portainer-https.entrypoints=https" - "traefik.http.routers.portainer-https.tls=true" - "traefik.http.routers.portainer-https.tls.certresolver=le" - "traefik.http.routers.portainer-https.service=portainer-svc" - "traefik.http.services.portainer-svc.loadbalancer.server.port=9000"volumes: portainer_data:
networks: traefik-public: external: true
- Assistant
- User
but i do not have it defined anywhere, but still see this in portainer ui portainer_agent.pazo5dd2lwowx... running
- Assistant
- User
2024/08/23 08:15AM INF ./main.go:86 > agent running on Docker platform 2024/08/23 08:15AM FTL ./main.go:92 > unable to retrieve information from Docker | error="Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
- Assistant
- User
after reboot ubuntu server i lost host.docker.internal, it is not accessible from traefik container, what should i do to fix?
- Assistant
- User
you are right, i have this line - “host.docker.internal:172.17.0.1” # Replace with actual host IP but ip is different after reboot and docker restarted?
- Assistant