From 0bcac4256bdf24f4d404dc850d319cb44115c2f2 Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 14:32:09 +0330 Subject: [PATCH 1/6] use filter on downstream_cx_active stats url Add a filter to prometheus stats url so that only the desired stats are returned. This improves the performance especially in clusters with high number of routes Signed-off-by: Ahmad Karimi --- cmd/contour/shutdownmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/contour/shutdownmanager.go b/cmd/contour/shutdownmanager.go index 305a5303903..5d3f3c83a7b 100644 --- a/cmd/contour/shutdownmanager.go +++ b/cmd/contour/shutdownmanager.go @@ -31,7 +31,7 @@ import ( ) const ( - prometheusURL = "http://unix/stats/prometheus" + prometheusURL = "http://unix/stats/prometheus?filter=http\\..*\\.downstream_cx_active" healthcheckFailURL = "http://unix/healthcheck/fail" prometheusStat = "envoy_http_downstream_cx_active" ) From 083b4c41cd55ac565ea0c622ccde378fbda7a1a8 Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 15:04:16 +0330 Subject: [PATCH 2/6] add release note Signed-off-by: Ahmad Karimi --- changelogs/unreleased/6523-therealak12-small.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/unreleased/6523-therealak12-small.md diff --git a/changelogs/unreleased/6523-therealak12-small.md b/changelogs/unreleased/6523-therealak12-small.md new file mode 100644 index 00000000000..460d3bc87a5 --- /dev/null +++ b/changelogs/unreleased/6523-therealak12-small.md @@ -0,0 +1 @@ +- Improve response time by utilizing a query param (`filter=http\..*\.downstream_cx_active`) when querying `/stats/prometheus` for `envoy_http_downstream_cx_active` From 9aa32e1d40a20b64c71370a679f17d10609248ef Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 19:56:56 +0330 Subject: [PATCH 3/6] improve release note Signed-off-by: Ahmad Karimi --- changelogs/unreleased/6523-therealak12-small.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/6523-therealak12-small.md b/changelogs/unreleased/6523-therealak12-small.md index 460d3bc87a5..97589658064 100644 --- a/changelogs/unreleased/6523-therealak12-small.md +++ b/changelogs/unreleased/6523-therealak12-small.md @@ -1 +1 @@ -- Improve response time by utilizing a query param (`filter=http\..*\.downstream_cx_active`) when querying `/stats/prometheus` for `envoy_http_downstream_cx_active` +Improve response time by utilizing a query param (`filter=http\..*\.downstream_cx_active`) when querying `/stats/prometheus` for `envoy_http_downstream_cx_active` in the shutdown-manager. From b2ed096b522d12d56b2a1c1008d208928195b78a Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 19:59:44 +0330 Subject: [PATCH 4/6] add comment for prometheusURL Signed-off-by: Ahmad Karimi --- cmd/contour/shutdownmanager.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/contour/shutdownmanager.go b/cmd/contour/shutdownmanager.go index 5d3f3c83a7b..37686339bb3 100644 --- a/cmd/contour/shutdownmanager.go +++ b/cmd/contour/shutdownmanager.go @@ -31,6 +31,8 @@ import ( ) const ( + // The prometheusURL is used to fetch the envoy metrics. Note that the filter + // value matches Envoy's raw stat names (i.e. those on the `/stats/` endpoint). prometheusURL = "http://unix/stats/prometheus?filter=http\\..*\\.downstream_cx_active" healthcheckFailURL = "http://unix/healthcheck/fail" prometheusStat = "envoy_http_downstream_cx_active" From 394af7a08d0e9c789b13df9eb927650d22432f67 Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 20:01:23 +0330 Subject: [PATCH 5/6] use more stricter regex Signed-off-by: Ahmad Karimi --- cmd/contour/shutdownmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/contour/shutdownmanager.go b/cmd/contour/shutdownmanager.go index 37686339bb3..fc22a473ba0 100644 --- a/cmd/contour/shutdownmanager.go +++ b/cmd/contour/shutdownmanager.go @@ -33,7 +33,7 @@ import ( const ( // The prometheusURL is used to fetch the envoy metrics. Note that the filter // value matches Envoy's raw stat names (i.e. those on the `/stats/` endpoint). - prometheusURL = "http://unix/stats/prometheus?filter=http\\..*\\.downstream_cx_active" + prometheusURL = "http://unix/stats/prometheus?filter=^http\\..*\\.downstream_cx_active$" healthcheckFailURL = "http://unix/healthcheck/fail" prometheusStat = "envoy_http_downstream_cx_active" ) From f0a7e54f2304f954b24346755ef50bf82a9c770a Mon Sep 17 00:00:00 2001 From: Ahmad Karimi Date: Thu, 20 Jun 2024 20:02:05 +0330 Subject: [PATCH 6/6] improve changelog message Signed-off-by: Ahmad Karimi --- changelogs/unreleased/6523-therealak12-small.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/6523-therealak12-small.md b/changelogs/unreleased/6523-therealak12-small.md index 97589658064..478f6666603 100644 --- a/changelogs/unreleased/6523-therealak12-small.md +++ b/changelogs/unreleased/6523-therealak12-small.md @@ -1 +1 @@ -Improve response time by utilizing a query param (`filter=http\..*\.downstream_cx_active`) when querying `/stats/prometheus` for `envoy_http_downstream_cx_active` in the shutdown-manager. +Improve shutdown manager query to the Envoy stats endpoint for active connections by utilizing a regex filter query param.