2022-04-15 13:44:08 +00:00
---
title: "Traefik Prometheus Documentation"
description: "Traefik supports several metrics backends, including Prometheus. Learn how to implement it for observability in Traefik Proxy. Read the technical documentation."
---
2019-07-18 19:36:05 +00:00
# Prometheus
To enable the Prometheus:
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
2019-07-18 19:36:05 +00:00
metrics:
prometheus: {}
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
```
2019-07-18 19:36:05 +00:00
```bash tab="CLI"
2019-07-22 07:58:04 +00:00
--metrics.prometheus=true
2019-07-18 19:36:05 +00:00
```
#### `buckets`
_Optional, Default="0.100000, 0.300000, 1.200000, 5.000000"_
Buckets for latency metrics.
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
2019-07-18 19:36:05 +00:00
metrics:
prometheus:
buckets:
2019-09-23 15:00:06 +00:00
- 0.1
- 0.3
- 1.2
- 5.0
2019-07-18 19:36:05 +00:00
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
buckets = [0.1,0.3,1.2,5.0]
```
2019-07-18 19:36:05 +00:00
```bash tab="CLI"
2022-02-03 14:16:12 +00:00
--metrics.prometheus.buckets=0.1,0.3,1.2,5.0
2019-07-18 19:36:05 +00:00
```
#### `addEntryPointsLabels`
_Optional, Default=true_
Enable metrics on entry points.
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
2019-07-18 19:36:05 +00:00
metrics:
prometheus:
addEntryPointsLabels: true
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
addEntryPointsLabels = true
```
2019-07-18 19:36:05 +00:00
```bash tab="CLI"
--metrics.prometheus.addEntryPointsLabels=true
```
2021-11-08 12:32:10 +00:00
#### `addRoutersLabels`
2021-04-30 08:22:04 +00:00
_Optional, Default=false_
Enable metrics on routers.
```yaml tab="File (YAML)"
metrics:
prometheus:
addRoutersLabels: true
```
2022-02-03 14:16:12 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
addRoutersLabels = true
```
2021-04-30 08:22:04 +00:00
```bash tab="CLI"
--metrics.prometheus.addrouterslabels=true
```
2019-07-18 19:36:05 +00:00
#### `addServicesLabels`
_Optional, Default=true_
Enable metrics on services.
2019-07-22 07:58:04 +00:00
```yaml tab="File (YAML)"
2019-07-18 19:36:05 +00:00
metrics:
prometheus:
addServicesLabels: true
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
addServicesLabels = true
```
2019-07-18 19:36:05 +00:00
```bash tab="CLI"
--metrics.prometheus.addServicesLabels=true
```
2019-09-06 13:08:04 +00:00
#### `entryPoint`
_Optional, Default=traefik_
Entry point used to expose metrics.
```yaml tab="File (YAML)"
entryPoints:
metrics:
2022-02-03 14:16:12 +00:00
address: :8082
2019-09-06 13:08:04 +00:00
metrics:
prometheus:
entryPoint: metrics
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[entryPoints]
[entryPoints.metrics]
address = ":8082"
[metrics]
[metrics.prometheus]
entryPoint = "metrics"
```
2019-09-06 13:08:04 +00:00
```bash tab="CLI"
2019-11-19 09:18:05 +00:00
--entryPoints.metrics.address=:8082
--metrics.prometheus.entryPoint=metrics
2019-09-06 13:08:04 +00:00
```
2019-11-14 15:40:05 +00:00
#### `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 `prometheus@internal` service.
```yaml tab="File (YAML)"
metrics:
prometheus:
manualRouting: true
```
2021-06-18 22:08:08 +00:00
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
manualRouting = true
```
2019-11-14 15:40:05 +00:00
```bash tab="CLI"
--metrics.prometheus.manualrouting=true
```
2023-03-20 17:06:07 +00:00
#### `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.
```yaml tab="File (YAML)"
metrics:
prometheus:
headerLabels:
label: headerKey
```
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
[metrics.prometheus.headerLabels]
label = "headerKey"
```
```bash tab="CLI"
--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:
```yaml tab="File (YAML)"
metrics:
prometheus:
headerLabels:
useragent: User-Agent
```
```toml tab="File (TOML)"
[metrics]
[metrics.prometheus]
[metrics.prometheus.headerLabels]
useragent = "User-Agent"
```
```bash tab="CLI"
--metrics.prometheus.headerlabels.useragent=User-Agent
```
And performing a request with a custom User-Agent:
```bash
curl -H "User-Agent: foobar" http://localhost
```
The following metric is produced :
```bash
traefik_entrypoint_requests_total{code="200",entrypoint="web",method="GET",protocol="http",useragent="foobar"} 1
```