監控
官方文檔地址:https://doc.traefik.io/traefik/observability/metrics/overview/
可以使用多種監控軟件,比如Datadog,InfluxDB,Prometheus,StatsD
在這里使用Prometheus
--api.debug=true
--metrics.prometheus=true
--metrics.prometheus.addEntryPointsLabels=true
--metrics.prometheus.addrouterslabels=true
--metrics.prometheus.addServicesLabels=true
--entryPoints.metrics.address=:8082
--metrics.prometheus.entryPoint=metrics
--metrics.prometheus.manualrouting=true
日志
官方文檔地址:https://doc.traefik.io/traefik/observability/access-logs/
--accesslog=true
--accesslog.format=json # text
--log.filePath=/path/to/traefik.log #可以創建數據卷把這個路徑給掛載出去
--log.level=DEBUG # DEBUG, PANIC, FATAL, ERROR, WARN, INFO
--accesslog.fields.defaultmode=keep
--accesslog.fields.names.ClientUsername=drop
--accesslog.fields.headers.defaultmode=keep
--accesslog.fields.headers.names.User-Agent=redact
--accesslog.fields.headers.names.Authorization=drop
--accesslog.fields.headers.names.Content-Type=keep
追蹤
官方文檔地址:https://doc.traefik.io/traefik/observability/tracing/elastic/
Traefik支持六個跟蹤后端:Jaeger,Zipkin,Datadog,Instana,Haystack,Elastic
在這里是作為Elastic APM Agent來進行處理的,所以配置的是Elastic APM server相關參數
--tracing=true
--tracing.serviceName=traefik
--tracing.spanNameLimit=150
--tracing.elastic=true
--tracing.elastic.serverurl="http://apm:8200"
--tracing.elastic.secrettoken="mytoken"
--tracing.elastic.serviceenvironment="production"