Skip to content

Latest commit

 

History

History
98 lines (76 loc) · 4.3 KB

traefik-observability.md

File metadata and controls

98 lines (76 loc) · 4.3 KB

Traefik Observability Lab

Traefik Logo

1. Enable Debug logging for Traefik

  1. Before we begin, lets cleanup any running Docker stack docker stack rm traefik If you named you stack something else use your specified name. If you don't remember run docker stack ls
  2. Change to the 06-Observability folder
  3. Open the traefik.yml file in your favorite editor and review the Traefik Logging section
  4. Change the Log level from INFO to DEBUG
log:
  level: DEBUG
  1. Start Traefik and the catapp docker stack deploy -c docker-compose.log.yml traefik
  2. View the Debug logs docker service logs traefik_traefik
  3. Once we are done with Debug switch Traefik back to default logging. Open traefik.yml and change the Log level from DEBUG to INFO
log:
  level: INFO
  1. Remove Traefik docker stack rm traefik
  2. Redeploy Traefik with the updated Log Level docker stack deploy -c docker-compose.log.yml traefik
  3. View the ERROR Log level for Traefik docker service logs traefik_traefik

2. Enable Access Logs

  1. Before we begin, lets cleanup the HTTP stack docker stack rm traefik If you named you stack something else use your specified name. If you don't remember run docker stack ls
  2. Change to the 06-Observability folder
  3. Open the traefik.access-log.yml file in your favorite editor and review the Access Logging section
  4. Uncomment the accessLog line to enable Access Logging
# enable Access logs
accessLog: {}
  1. Start Traefik with Access Log enabled docker stack deploy -c docker-compose.access-log.yml traefik
  2. Open http://catapp.localhost and refresh the page a couple times
  3. View the Access Log using docker service logs traefik_traefik see the example below of a 200 status message
traefik_traefik.1.zaxcbu7aplii@docker-desktop    | 10.0.0.2 - traefik [04/Sep/2020:07:52:41 +0000] "GET / HTTP/1.1" 200 760 "-" "-" 1 "catapp@docker" "http://10.0.8.6:5000" 14ms
  1. Let's enable filtering to see just 404 status messages. Edit the Access Log filter configuration in traefik.access-log.ymland comment the Access Log and uncomment the filtering section
# accessLog: {}
#Configuring Multiple Filters
accessLog:
  filters:    
    statusCodes:
      - "404"
    retryAttempts: true
    minDuration: "10ms"
  1. Remove Traefik docker stack rm traefik
  2. Redeploy Traefik with the updated Access Log filter docker stack deploy -c docker-compose.access-log.yml traefik
  3. Open http://catapp.localhost and refresh the page a couple times
  4. View the Access Log using docker service logs traefik_traefik see the example below of a 200 status message
  5. Create a 404 error by opening a missing path http://catapp.localhost/missing
  6. View the Access Log using docker service logs traefik_traefik and we should only see a 404 status message

3. Enable Traefik Metrics

  1. Before we begin, lets cleanup the HTTP stack docker stack rm traefik If you named you stack something else use your specified name. If you don't remember run docker stack ls
  2. Change to the 06-Observability folder
  3. Open the traefik.metrics.yml file in your favorite editor and review the Prometheus Metrics section. The buckets Prometheus metrics buckets have been enabled for the different time series in seconds.
metrics:
  prometheus:
    buckets:
      - 0.1
      - 0.3
      - 1.2
      - 5.0
  1. Start Traefik with Metrics enabled docker stack deploy -c docker-compose.metrics.yml traefik

NOTE: This will take a couple minutes as Prometheus and Grafana need to download and start

  1. Login to Promethes prometheus.localhost
  2. Review the available metrics imported into Prometheus by opening Graph and then click the dropdown and scroll to the bottom to find Traefik metrics
  3. Login to Grafana grafana.localhost
  4. Grafana user is admin and password is foobar
  5. Open the Dashboard Traefik2
  6. Visualize the Stats from Traefik

Continue to the Next Operations

Click here to continue -> Operations Lab