- Before we begin, lets cleanup any running Docker stack
docker stack rm traefikIf you named you stack something else use your specified name. If you don't remember rundocker stack ls - Change to the
06-Observabilityfolder - Open the
traefik.ymlfile in your favorite editor and review theTraefik Loggingsection - Change the Log level from
INFOtoDEBUG
log:
level: DEBUG- Start Traefik and the
catappdocker stack deploy -c docker-compose.log.yml traefik - View the Debug logs
docker service logs traefik_traefik - Once we are done with Debug switch Traefik back to default logging. Open
traefik.ymland change the Log level fromDEBUGtoINFO
log:
level: INFO- Remove Traefik
docker stack rm traefik - Redeploy Traefik with the updated Log Level
docker stack deploy -c docker-compose.log.yml traefik - View the
ERRORLog level for Traefikdocker service logs traefik_traefik
- Before we begin, lets cleanup the HTTP stack
docker stack rm traefikIf you named you stack something else use your specified name. If you don't remember rundocker stack ls - Change to the
06-Observabilityfolder - Open the
traefik.access-log.ymlfile in your favorite editor and review theAccess Loggingsection - Uncomment the
accessLogline to enable Access Logging
# enable Access logs
accessLog: {}- Start Traefik with
Access Logenableddocker stack deploy -c docker-compose.access-log.yml traefik - Open http://catapp.localhost and refresh the page a couple times
- View the
Access Logusingdocker service logs traefik_traefiksee the example below of a200status 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- Let's enable filtering to see just
404status messages. Edit theAccess Logfilter configuration intraefik.access-log.ymland comment theAccess Logand uncomment the filtering section
# accessLog: {}
#Configuring Multiple Filters
accessLog:
filters:
statusCodes:
- "404"
retryAttempts: true
minDuration: "10ms"- Remove Traefik
docker stack rm traefik - Redeploy Traefik with the updated
Access Logfilterdocker stack deploy -c docker-compose.access-log.yml traefik - Open http://catapp.localhost and refresh the page a couple times
- View the
Access Logusingdocker service logs traefik_traefiksee the example below of a200status message - Create a
404error by opening a missing path http://catapp.localhost/missing - View the
Access Logusingdocker service logs traefik_traefikand we should only see a404status message
- Before we begin, lets cleanup the HTTP stack
docker stack rm traefikIf you named you stack something else use your specified name. If you don't remember rundocker stack ls - Change to the
06-Observabilityfolder - Open the
traefik.metrics.ymlfile in your favorite editor and review thePrometheus Metricssection. 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- Start Traefik with
Metricsenableddocker stack deploy -c docker-compose.metrics.yml traefik
NOTE: This will take a couple minutes as Prometheus and Grafana need to download and start
- Login to Promethes prometheus.localhost
- Review the available metrics imported into Prometheus by opening Graph and then click the dropdown and scroll to the bottom to find Traefik metrics
- Login to Grafana grafana.localhost
- Grafana user is
adminand password isfoobar - Open the Dashboard
Traefik2 - Visualize the Stats from Traefik
