Traefik

Monitor Traefik on Kubernetes (k3s's default ingress), Docker and Linux servers with WatchLog: hosts, routers, URL patterns, services with no server up, retries, latency in Traefik and in the backend, certificates and reloads, from Traefik's access log (read on your machine) and its metrics.

Traefik monitoring: what WatchLog shows and explains →

WatchLog finds Traefik from the images and processes your agents already see: the official image and k3s's bundled one (rancher/mirrored-library-traefik) on Kubernetes and Docker, and a traefik binary on a Linux server. Open Applications and press Monitor: Traefik needs no user or password. Traefik 2.10 and later, and 3.x.

How it works

Two sources, either or both:

  • Its access log, read on the machine. The WatchLog agent where Traefik runs reads its access log (the pod's stdout on Kubernetes, the container's on Docker, the file accessLog.filePath names on a server) and turns each line into counts there: hosts, routers, services, URL patterns, status codes, the time in Traefik and in the backend, retries, client addresses. Lines never leave the machine and are never stored. Query strings are cut before anything else; ids, UUIDs, hashes and tokens in a path become placeholders (/cart/{id}). Traefik's own routers (api@internal, prometheus@internal) are left out.
  • Its Prometheus metrics (entrypoints, services, servers up with health checks, TLS certificates, reloads, Traefik's own memory and CPU), read where Traefik serves them.

Requests, 5xx and p95 come from the log when it is read (it has hosts and URLs), else from the metrics, else from eBPF: one source for each number, so the page agrees with itself.

Client addresses are kept like Nginx's: the 50 busiest for 24 hours, shortened to their networks or not kept at all, from Settings → General → Client addresses.

What it needs

  • Its access log, in JSON for everything. Traefik writes none by default. Turn it on:

    # Helm (the traefik chart): values.yaml
    logs:
      access:
        enabled: true
        format: json
    

    or the flags --accesslog=true --accesslog.format=json, or in traefik.yml accessLog: {format: json}. On a server whose Traefik writes to the journal, give it a file: accessLog: {filePath: /var/log/traefik/access.log, format: json}. Traefik's default (common) format works too, with less: no host (routers stand in), no service name, no time in the backend, no retries. The Setup drawer says which you have and the one step to add the rest.

  • Traefik's Prometheus metrics. WatchLog reads them where Traefik serves them: :9100/metrics (the metrics entrypoint of Traefik's Helm chart and of k3s's bundled Traefik, on by default), :8080/metrics (the default traefik entrypoint) or :8082/metrics. Nothing else is requested, apart from /api/version on :8080 for the version when the API answers.

  • When they're off, requests, errors and latency come from the node agents' eBPF (plain HTTP only), and the page gives the setting for your install:

    • k3s: a HelmChartConfig for the bundled chart:

      apiVersion: helm.cattle.io/v1
      kind: HelmChartConfig
      metadata:
        name: traefik
        namespace: kube-system
      spec:
        valuesContent: |-
          metrics:
            prometheus:
              entryPoint: metrics
      
    • Helm: helm upgrade <release> traefik/traefik -n <namespace> --reuse-values --set metrics.prometheus.entryPoint=metrics

    • Docker and anything else, three flags:

      --entrypoints.metrics.address=:9100 --metrics.prometheus=true --metrics.prometheus.entrypoint=metrics
      

    WatchLog looks again every minute for the first 10 minutes, then every 10 minutes.

  • Docker 29 needs Traefik 3.6.1 or later. Older versions' Docker provider speaks API 1.24, which Docker 29 refuses, so Traefik routes nothing; WatchLog can't fix that.

  • Optional: --metrics.prometheus.addRoutersLabels=true adds per-router numbers; health checks on a service (loadbalancer.healthcheck.path) add its servers up and down.

What you see

The page is one scroll, top to bottom:

  • Right now. One sentence ("Service cart has no server up." or "4% of requests fail." or "Everything is answering."), the cause in a line ("Traefik answers 503 for cart itself: 38/s turned away. Its backend shop/cart has 0 pods ready. Since 14:02, after "cart rolled out" at 14:01."), See what broke and Open the backend's workload, and four numbers: requests a second, the 5xx share, p95, services up.
  • The chart, with four views: Status (answered fine, 4xx, 5xx, and the p95 line), Latency (p50, p95, p99), Bandwidth (in and out) and Connections (open, by entrypoint). Rollouts of the backends and Traefik's reloads are pills on it. Drag on it to choose a period: every section and drawer follows.
  • Where requests go: each host on the left, the service that answers it on the right (routers stand in for hosts with the common format or the metrics alone). A service with no server up is red, with the requests Traefik turned away for it.
  • Routers, worst first, each with its rate, 5xx and p95; All routers opens the whole list.
  • Why it fails: no server up (Traefik's own 503), the backend answering 5xx itself, a backend Traefik can't reach or that doesn't answer in time, and what Traefik answered itself (a rate or in-flight limit's 429), each with its share and since when.
  • Everything else: Certificates, Middlewares (requests a limit turned away, retries), Traefik itself (memory, CPU, reloads, restarts) and Clients.

Drawers. A service's drawer has its cause first, its servers, its routers and its URL patterns; a router's, its service, URLs and failures; a host's, its routers. They are in the address (?open=service:cart@file), so a link can be sent.

Everything the earlier tabs showed is in a drawer of its own:

View What it shows
Overview The tab from before 1.7, as it was
Services Each service with its backend, requests, 5xx, p95, servers up and retries
Entrypoints Requests and open connections by entrypoint, certificates and their expiry, configuration reloads
Routers Every router with its service, requests, 5xx and p95 (from the log, or addRoutersLabels)
URLs Every URL pattern with its router, requests, 5xx and p95 (the log)
Clients The busiest addresses (the log; your Client addresses setting applies)
Middlewares Requests turned away by a limit, retries, what Traefik answered itself
Setup What WatchLog reads (the log, its format, the metrics, health checks) and the one step that adds the rest

Backends. Traefik names its services after where they come from. WatchLog maps them back: <namespace>-<service>-<port>@kubernetes (an Ingress) is that Service and its workload; <namespace>-<route>-<hash>@kubernetescrd (an IngressRoute) carries a hash in place of the Service, so it is shown as the IngressRoute; on Docker, <service>-<project>@docker is that Compose service's container, and a name set by a label (traefik.http.services.<name>…) is matched to a container or Compose service of that name.

On the service map

The map's HTTP numbers come from eBPF on plain-HTTP connections. Traefik adds what eBPF can't see, and never counts a request twice:

  • An edge from Traefik to a backend with no eBPF HTTP numbers (TLS or HTTP/2 to the backend) gets Traefik's, marked "from Traefik".
  • Requests Traefik answered itself because the backend has no server up ("no available server", 503) are shown on the edge to that backend: "12/s answered by Traefik: no server up". No connection is made, so nothing else sees them.
  • The Traefik node shows each entrypoint's requests, 5xx and TLS requests, which no edge carries when clients come from outside the cluster.

What WatchLog tells you

A service with no server up, with its backend linked (probable cause follows it to the backend's own cause: scaled to 0, crashing, out of memory); the 5xx share, with the service that sends most of them and its workload's last rollout; a high p95; a certificate that expires within 14 days; a failed configuration reload (Traefik 2); and the metrics setting above.

Default alerts

Created when you start monitoring; the drawer's ticks decide which start on.

  • More than 5 % of requests answer 5xx for 5 minutes (critical)
  • p95 above 1 s for 5 minutes (warning)
  • A service with no server up for a minute (critical)
  • A certificate expires within 14 days (warning)
  • The last configuration reload failed (warning, Traefik 2)
  • The service unreachable, or slow to connect (every service has these)

What it costs

Parsing and counting one access-log line takes about 2.3 µs in JSON and 1.6 µs in the common format (one core: 1,000 lines a second is 0.2 % of it). Each Traefik sends at most about 1,500 series for its log (50 routers, 100 URL patterns, 20 services, 50 addresses). The Setup drawer shows the reader's own time. --traefik-logs=false (WATCHLOG_TRAEFIK_LOGS=false) turns it off.

Not available

  • Middleware names: neither Traefik 2 nor 3 exports them, in its metrics or its access log; the requests a limit turned away are counted, not which middleware.
  • A circuit breaker apart from no server up: both answer 503 without a server; they are told apart only by servers up (health checks).
  • Routers without the log, unless Traefik exports them (addRoutersLabels, off by default): services are the closest.
  • Servers up and down, unless the service has a health check: WatchLog uses the Service's ready endpoints (Kubernetes) and the container's state (Docker) instead.
  • A failed reload on Traefik 3: it no longer reports failures, only the last success.
  • A Docker container that stopped: Traefik's Docker provider removes its route, so requests get a 404 from another route or none; WatchLog shows the container stopped, not a service with no server up.