- 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 rundocker stack ls
- Change to the
06-Observability
folder - Open the
traefik.yml
file in your favorite editor and review theTraefik Logging
section - Change the Log level from
INFO
toDEBUG
log:
level: DEBUG
- Start Traefik and the
catapp
docker 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.yml
and change the Log level fromDEBUG
toINFO
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
ERROR
Log level for Traefikdocker service logs traefik_traefik
- 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 rundocker stack ls
- Change to the
06-Observability
folder - Open the
traefik.access-log.yml
file in your favorite editor and review theAccess Logging
section - Uncomment the
accessLog
line to enable Access Logging
# enable Access logs
accessLog: {}
- Start Traefik with
Access Log
enableddocker stack deploy -c docker-compose.access-log.yml traefik
- Open http://catapp.localhost and refresh the page a couple times
- View the
Access Log
usingdocker service logs traefik_traefik
see the example below of a200
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
- Let's enable filtering to see just
404
status messages. Edit theAccess Log
filter configuration intraefik.access-log.yml
and comment theAccess Log
and 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 Log
filterdocker stack deploy -c docker-compose.access-log.yml traefik
- Open http://catapp.localhost and refresh the page a couple times
- View the
Access Log
usingdocker service logs traefik_traefik
see the example below of a200
status message - Create a
404
error by opening a missing path http://catapp.localhost/missing - View the
Access Log
usingdocker service logs traefik_traefik
and we should only see a404
status message
- 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 rundocker stack ls
- Change to the
06-Observability
folder - Open the
traefik.metrics.yml
file in your favorite editor and review thePrometheus 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
- Start Traefik with
Metrics
enableddocker 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
admin
and password isfoobar
- Open the Dashboard
Traefik2
- Visualize the Stats from Traefik