Prometheus

To enable the Prometheus:

File (YAML)

  1. metrics:
  2. prometheus: {}

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]

CLI

  1. --metrics.prometheus=true

buckets

Optional, Default=”0.100000, 0.300000, 1.200000, 5.000000”

Buckets for latency metrics.

File (YAML)

  1. metrics:
  2. prometheus:
  3. buckets:
  4. - 0.1
  5. - 0.3
  6. - 1.2
  7. - 5.0

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. buckets = [0.1,0.3,1.2,5.0]

CLI

  1. --metrics.prometheus.buckets=0.1,0.3,1.2,5.0

addEntryPointsLabels

Optional, Default=true

Enable metrics on entry points.

File (YAML)

  1. metrics:
  2. prometheus:
  3. addEntryPointsLabels: true

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. addEntryPointsLabels = true

CLI

  1. --metrics.prometheus.addEntryPointsLabels=true

addRoutersLabels

Optional, Default=false

Enable metrics on routers.

File (YAML)

  1. metrics:
  2. prometheus:
  3. addRoutersLabels: true

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. addRoutersLabels = true

CLI

  1. --metrics.prometheus.addrouterslabels=true

addServicesLabels

Optional, Default=true

Enable metrics on services.

File (YAML)

  1. metrics:
  2. prometheus:
  3. addServicesLabels: true

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. addServicesLabels = true

CLI

  1. --metrics.prometheus.addServicesLabels=true

entryPoint

Optional, Default=traefik

Entry point used to expose metrics.

File (YAML)

  1. entryPoints:
  2. metrics:
  3. address: :8082
  4. metrics:
  5. prometheus:
  6. entryPoint: metrics

File (TOML)

  1. [entryPoints]
  2. [entryPoints.metrics]
  3. address = ":8082"
  4. [metrics]
  5. [metrics.prometheus]
  6. entryPoint = "metrics"

CLI

  1. --entryPoints.metrics.address=:8082
  2. --metrics.prometheus.entryPoint=metrics

manualRouting

Optional, Default=false

If manualRouting is true, it disables the default internal router in order to allow one to create a custom router for the [[email protected]](https://doc.traefik.io/cdn-cgi/l/email-protection) service.

File (YAML)

  1. metrics:
  2. prometheus:
  3. manualRouting: true

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. manualRouting = true

CLI

  1. --metrics.prometheus.manualrouting=true

headerLabels

Optional

Defines the extra labels for the requests_total metrics, and for each of them, the request header containing the value for this label. Please note that if the header is not present in the request it will be added nonetheless with an empty value. In addition, the label should be a valid label name for Prometheus metrics, otherwise, the Prometheus metrics provider will fail to serve any Traefik-related metric.

File (YAML)

  1. metrics:
  2. prometheus:
  3. headerLabels:
  4. label: headerKey

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. [metrics.prometheus.headerLabels]
  4. label = "headerKey"

CLI

  1. --metrics.prometheus.headerlabels.label=headerKey
Example

Here is an example of the entryPoint requests_total metric with an additional “useragent” label.

When configuring the label in Static Configuration:

File (YAML)

  1. metrics:
  2. prometheus:
  3. headerLabels:
  4. useragent: User-Agent

File (TOML)

  1. [metrics]
  2. [metrics.prometheus]
  3. [metrics.prometheus.headerLabels]
  4. useragent = "User-Agent"

CLI

  1. --metrics.prometheus.headerlabels.useragent=User-Agent

And performing a request with a custom User-Agent:

  1. curl -H "User-Agent: foobar" http://localhost

The following metric is produced :

  1. traefik_entrypoint_requests_total{code="200",entrypoint="web",method="GET",protocol="http",useragent="foobar"} 1