0

I have asked this question at official Traefik Community Forum and I have not received any replies there yet so I am hoping I have better luck here :)

I am trying to run a traefik-grafana-prometheus stack in my docker swarm node but for some reason my error logs are empty. I was able to grep and tail the docker service logs on my Ubuntu 20.04LTS and able to get some info. I followed instructions from here for installing: https://github.com/vegasbrianc/docker-traefik-prometheus

Any help would be greatly appreciated. :D

docker-traefik-letsencrypt docker-compose.yml (traefik working with minimal errors)

version: '3.7'

services:

  traefik:
    image: traefik:2.3.2
    ports:
      #- "80:80"
      #- "443:443"
      - target: 80
        published: 80
        mode: host
      - target: 443
        published: 443
        mode : host 
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M
      placement:
        constraints:
          # Make the traefik service run only on the node with this label
          # as the node with it has the volume for the certificates
          - node.labels.reverse-proxy.reverse-proxy-certificates == true
          - node.role == manager
      labels:
        - constraint-label=reverse-proxy
        - traefik.enable=true
        - traefik.docker.network=reverse-proxy
        #- traefik.http.middlewares.admin-auth.basicauth.users=${USERNAME}:${HASHED_PASSWORD}
        - traefik.http.middlewares.admin-auth.basicauth.users=admin:$$apr1$$8rWpRRHx$$xSzTeoNckKYO/umQnKso91
        - traefik.http.routers.reverse-proxy-https.rule=Host(`traefik.whiskeyonthe.rocks`)
        - traefik.http.routers.reverse-proxy-https.entrypoints=web,web-secure
        - traefik.http.routers.reverse-proxy-https.tls=true
        - traefik.http.routers.reverse-proxy-https.service=api@internal
        - traefik.http.routers.reverse-proxy-https.tls.certresolver=le
        - traefik.http.routers.reverse-proxy-https.middlewares=admin-auth
        - traefik.http.routers.reverse-proxy.tls.domains[0].main=whiskeyonthe.rocks
        - traefik.http.routers.reverse-proxy.tls.domains[0].sans=*.whiskeyonthe.rocks
      
        - traefik.http.services.reverse-proxy.loadbalancer.server.port=8080

    volumes:
      # Add Docker as a mounted volume, so that Traefik can read the labels of other services
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      # Mount the volume to store the certificates
      - "/srv/traefik.whiskeyonthe.rocks/certs:/certificates"
      - "/srv/traefik.whiskeyonthe.rocks/letsencrypt:/letsencrypt"
      #- "reverse-proxy-certificates:/certificates"
      #- "reverse-proxy-certificates:/letsencrypt"
    command:
      - --accesslog
      - '--pilot.token=71b1d833-0f8f-42e9-9087-3c117c81e327' 
      - --log
      - --log.level=DEBUG
      - --api
      - --providers.docker
      - --providers.docker.constraints=Label(`constraint-label`, `reverse-proxy`)
      - --providers.docker.exposedbydefault=false
      - --providers.docker.swarmmode
      - --entrypoints.web.address=:80
      # global redirect to https
      - --entrypoints.web.http.redirections.entryPoint.to=web-secure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.web-secure.address=:443
    
      - --certificatesresolvers.le.acme.email=${EMAIL}
      - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.le.acme.tlschallenge=true
      #- --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
    networks:
      # Use the public network created to be shared between Traefik and
      # any other service that needs to be publicly available with HTTPS
      - reverse-proxy
    extra_hosts:
      - EXTRA_HOSTS
    environment:
      - NODE_ID=63glxibxvxp4wvqpyrvnndvjt
      - EMAIL=admin@whiskeyonthe.rocks
      - DOMAIN=traefik.whiskeyonthe.rocks
      - USERNAME=admin
      #- USERPASS=echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g      
      #- $SRV_VPATH="/srv/DOMAIN.TLD/"
      - EXTRA_HOSTS="traefik.whiskeyonthe.rocks:185.193.127.125"
    env_file:
     - ./.env

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.whiskeyonthe.rocks`)"
      - "traefik.http.routers.whoami.middlewares=auth"
      - "traefik.http.routers.whoami.entrypoints=web,web-secure"
      - "traefik.http.routers.whoami.tls.certresolver=le"
    networks:
      - reverse-proxy

volumes:
  # Create a volume to store the certificates, there is a constraint to make sure
  # Traefik is always deployed to the same Docker node with the same volume containing
  # the HTTPS certificates
  reverse-proxy-certificates:
networks:
  # Use the previously created public network "reverse-proxy", shared with other
  # services that need to be publicly available via this Traefik
  reverse-proxy:
    external: true
    driver: overlay

.env file

ronin@ninjaserver:~$ cat docker-traefik-letsencrypt/.env
NODE_ID=53glxibxvxp5wvqpyrvnadvjt
EMAIL=admin@whiskeyonthe.rocks
DOMAIN=traefik.whiskeyonthe.rocks
USERNAME=admin
PASSWORD="changethis"
#HASHED_PASSWORD=$$apr1$$j9TccX.k$$lj7IVokmQdoz2TkJMFUnZ.
SRV_VPATH="/srv/traefik.whiskeyonthe.rocks/"
EXTRA_HOSTS="traefik.whiskeyonthe.rocks:185.193.127.125"
USERPASS=echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g

traefik_traefik error logs

ronin@ninjaserver:~$ docker service logs -f --no-trunc 

Here is the docker-traefik-prometheus docker-compose.yml I am comparing against and having issues getting to work.

ronin@ninjaserver:~$ cat docker-traefik-prometheus/docker-compose.yml
version: '3.7'
services:
  traefik:
    image: traefik:v2.3.2
    labels:
      - constraint.label=reverse-proxy
      - traefik.enable=true
      - traefik.docker.network=reverse-proxy
      - traefik.http.middlewares.admin-auth.basicauth.users=admin:$$apr1$$8rWpRRHx$$xSzTeoNckKYO/umQnKso91
      - traefik.http.routers.reverse-proxy-https.rule=Host(`traefik.whiskeyonthe.rocks`)
      - traefik.http.routers.reverse-proxy-https.entrypoints=web,web-secure
      - traefik.http.routers.reverse-proxy-https.tls=true
      - traefik.http.routers.reverse-proxy-https.service=api@internal
      - traefik.http.routers.reverse-proxy-https.tls.certresolver=le
      - traefik.http.routers.reverse-proxy-https.middlewares=admin-auth
      - traefik.http.routers.reverse-proxy.tls.domains[0].main=whiskeyonthe.rocks
      - traefik.http.routers.reverse-proxy.tls.domains[0].sans=*.whiskeyonthe.rocks
      - traefik.http.services.reverse-proxy.loadbalancer.server.port=8080
    command:
      - --log.level=DEBUG
      - "--accesslog"
      - "--log"
      - "--api"
      - "--api.insecure=true"
      - "--metrics.prometheus=true"
      - "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
      - "--providers.docker=true"
      - "--providers.docker.swarmmode=true"
      - "--providers.docker.watch"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.docker.constraints=Label(`constraint-label`, `reverse-proxy`)"
      - "--pilot.token=93693dd4-e757-437c-84e5-1722051218cc"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=web-secure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.web-secure.address=:443"
      - "--certificatesresolvers.le.acme.email=admin@whiskeyonthe.rocks"
      - "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.le.acme.tlschallenge=true"
    extra_hosts:
      - EXTRA_HOSTS
    environment:
      - NODE_ID=53glxibxvxp5wvqpyrvnadvjt
      - EMAIL=admin@whiskeyonthe.rocks
      - DOMAIN=traefik.whiskeyonthe.rocks
      - USERNAME=admin
      - EXTRA_HOSTS="traefik.whiskeyonthe.rocks:185.193.127.125"
    networks:
      - reverse-proxy
      - inbound
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - "/srv/traefik.whiskeyonthe.rocks/traefik/le:/letsencrypt"
      - traefik_data:/traefik
    ports:
      - target: 80
        published: 80
        mode: host
      - target: 443
        published: 443
        mode: host
      - target: 8080
        published: 8080
        protocol: tcp
        mode: ingress
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M
      mode: global
      placement:
        constraints:
          - node.role == manager
          - node.labels.reverse-proxy.traefik_data == true
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure
  prometheus:
    image: prom/prometheus
    volumes:
      - /srv/prometheus.whiskeyonthe.rocks/prometheus:/etc/prometheus/
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
      
    networks:
      - inbound
    extra_hosts:
      - "prometheus.whiskeyonthe.rocks:185.193.127.125"
    deploy:
      labels:
       - "traefik.enable=true"
       - "traefik.http.routers.prometheus.rule=Host(`prometheus.whiskeyonthe.rocks`)"
       - "traefik.http.routers.prometheus.service=prometheus"
       - "traefik.http.services.prometheus.loadbalancer.server.port=9090"
       - "traefik.docker.network=inbound"
       - "traefil.http.routers.prometheus.middlewares=auth"
       - "traefik.http.routers.prometheus.entrypoints=web,web-secure"
       - "traefik.http.routers.prometheus.tls.certresolver=le"
      placement:
        constraints:
        - node.role==manager
      restart_policy:
        condition: on-failure
  
  grafana:
    image: grafana/grafana
    depends_on:
      - prometheus
    volumes:
      - grafana_data:/var/lib/grafana
      - /srv/grafana.whiskeyonthe.rocks/grafana/provisioning/:/etc/grafana/provisioning/
    env_file:
      - /srv/grafana.whiskeyonthe.rocks/grafana/config.monitoring
    networks:
      - inbound
    extra_hosts: 
      - "grafana.whiskeyonth.rocks:185.193.127.125"
    user: "104"
    deploy:
      labels:
        - "traefik.http.routers.grafana.rule=Host(`grafana.whiskeyonthe.rocks`)"
        - "traefik.http.routers.grafana.service=grafana"
        - "traefik.http.services.grafana.loadbalancer.server.port=3000"
        - "traefik.docker.network=inbound"
        - "traefik.http.routers.grafana.middlewares=auth"
        - "traefik.http.routers.grafana.entrypoints=web,web-secure"
        - "traefik.http.routers.grafana.tls.certresolver=le"
      placement:
        constraints:
          - node.role == manager
      restart_policy:
        condition: on-failure

networks:
  reverse-proxy:
    external: true
    driver: overlay
    name: reverse-proxy
  inbound:
    driver: overlay
    name: inbound

volumes:
    prometheus_data: {}
    grafana_data: {}
    traefik_data: {}

traefik_traefik error logs

ronin@ninjaserver:~/docker-traefik-prometheus$ docker service logs -f --no-trunc traefik_traefik | grep -i error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.