Skip to content

Conversation

@tomMoulard
Copy link
Collaborator

@tomMoulard tomMoulard commented Sep 6, 2021

What does this PR do?

This PR intends to solve 2 issues in the metrics exports on routers:

The first is when you try to export more than once the metrics of a router. The first time, it exports the correct value, and the second time, metrics are not exported.

Metrics are not exported the second time
$ curl -S localhost/
Hostname: whoami-78447d957f-n75xz
IP: 127.0.0.1
IP: ::1
IP: 10.42.0.7
IP: fe80::dc7f:11ff:feb4:5088
RemoteAddr: 10.42.0.6:33288
GET / HTTP/1.1
Host: localhost
User-Agent: curl/7.68.0
Accept: application/json, application/xml, text/plain, */*
Accept-Encoding: gzip
X-Forwarded-For: 10.42.0.1
X-Forwarded-Host: localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: traefik-788d95b68f-tn7h7
X-Real-Ip: 10.42.0.1

$ curl -S localhost:8080/metrics | grep simpleingressroute | grep router
traefik_router_open_connections{method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52"} 0
traefik_router_request_duration_seconds_bucket{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52",le="0.1"} 4
traefik_router_request_duration_seconds_bucket{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52",le="0.3"} 4
traefik_router_request_duration_seconds_bucket{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52",le="1.2"} 4
traefik_router_request_duration_seconds_bucket{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52",le="5"} 4
traefik_router_request_duration_seconds_bucket{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52",le="+Inf"} 4
traefik_router_request_duration_seconds_sum{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52"} 0.002946457
traefik_router_request_duration_seconds_count{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52"} 4
traefik_router_requests_total{code="200",method="GET",protocol="http",router="default-simpleingressroute-5a0ff67b89637da8ca52@kubernetescrd",service="default-simpleingressroute-5a0ff67b89637da8ca52"} 4
$ curl -S localhost:8080/metrics | grep simpleingressroute | grep router
$

The second issue is related to the isOutdated method on the Prometheus exporter:
The exporter did not check if routers were still up-to-date, and if old routers needed to be removed from Prometheus metrics.

Motivation

Solve Prometheus metrics issues:

  • Have correct router metrics
  • Don't export metrics of removed routers

More

  • Added/updated tests
  • Added/updated documentation

Co-authored-by: Michael michael.matur@gmail.com
Co-authored-by: Romain rtribotte@users.noreply.github.com

@mmatur mmatur modified the milestones: next, 2.5 Sep 6, 2021
@tomMoulard tomMoulard changed the base branch from master to v2.5 September 6, 2021 13:08
@tomMoulard tomMoulard force-pushed the metrics-router-fix branch 2 times, most recently from 3e3763c to 8a25a44 Compare September 6, 2021 13:15
Copy link
Member

@rtribotte rtribotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@jbdoumenjou jbdoumenjou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tomMoulard tomMoulard force-pushed the metrics-router-fix branch 2 times, most recently from b4b38ad to f8799ca Compare September 15, 2021 08:07
@traefiker traefiker merged commit 6e28db5 into traefik:v2.5 Sep 15, 2021
@tomMoulard tomMoulard deleted the metrics-router-fix branch September 16, 2021 07:10
@rtribotte rtribotte changed the title Metrics router fix Fix Prometheus router's metrics Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants