From 89beee0543e7276d2543207872b708f421d1ecfb Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Thu, 6 Jul 2023 12:59:27 +0100 Subject: [PATCH 1/7] Expose Prometheus metrics for Services - Location Zones --- internal/configs/version1/nginx-plus.ingress.tmpl | 1 + internal/configs/version2/nginx-plus.virtualserver.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/configs/version1/nginx-plus.ingress.tmpl b/internal/configs/version1/nginx-plus.ingress.tmpl index 60b61acc05..4b1fd00913 100644 --- a/internal/configs/version1/nginx-plus.ingress.tmpl +++ b/internal/configs/version1/nginx-plus.ingress.tmpl @@ -179,6 +179,7 @@ server { {{range $location := $server.Locations}} location {{$location.Path}} { set $service "{{$location.ServiceName}}"; + status_zone "{{$location.ServiceName}}"; {{with $location.MinionIngress}} # location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}} set $resource_name "{{$location.MinionIngress.Name}}"; diff --git a/internal/configs/version2/nginx-plus.virtualserver.tmpl b/internal/configs/version2/nginx-plus.virtualserver.tmpl index c4c4b0e1f3..4ed5c802bb 100644 --- a/internal/configs/version2/nginx-plus.virtualserver.tmpl +++ b/internal/configs/version2/nginx-plus.virtualserver.tmpl @@ -1,7 +1,6 @@ {{ range $u := .Upstreams }} upstream {{ $u.Name }} { zone {{ $u.Name }} {{ if ne $u.UpstreamZoneSize "0" }}{{ $u.UpstreamZoneSize }}{{ else }}512k{{ end }}; - {{ if $u.LBMethod }}{{ $u.LBMethod }};{{ end }} {{ range $s := $u.Servers }} @@ -337,6 +336,7 @@ server { {{ range $l := $s.Locations }} location {{ $l.Path }} { set $service "{{ $l.ServiceName }}"; + status_zone {{ $l.ServiceName }}; {{ if $l.IsVSR }} set $resource_type "virtualserverroute"; set $resource_name "{{ $l.VSRName }}"; From e0944487b8fd5f921e5c8e912b9df5297ca7d2c2 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Thu, 6 Jul 2023 13:14:54 +0100 Subject: [PATCH 2/7] Keep original layout for tmpl --- internal/configs/version2/nginx-plus.virtualserver.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/configs/version2/nginx-plus.virtualserver.tmpl b/internal/configs/version2/nginx-plus.virtualserver.tmpl index 4ed5c802bb..7334e171e9 100644 --- a/internal/configs/version2/nginx-plus.virtualserver.tmpl +++ b/internal/configs/version2/nginx-plus.virtualserver.tmpl @@ -1,6 +1,7 @@ {{ range $u := .Upstreams }} upstream {{ $u.Name }} { zone {{ $u.Name }} {{ if ne $u.UpstreamZoneSize "0" }}{{ $u.UpstreamZoneSize }}{{ else }}512k{{ end }}; + {{ if $u.LBMethod }}{{ $u.LBMethod }};{{ end }} {{ range $s := $u.Servers }} From 47246c543838e14cb07d806d0ded5fbb3ea6422b Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Fri, 7 Jul 2023 11:45:21 +0100 Subject: [PATCH 3/7] Use paths as zone names in metrics and doshboard --- internal/configs/version1/nginx-plus.ingress.tmpl | 2 +- internal/configs/version2/nginx-plus.virtualserver.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/configs/version1/nginx-plus.ingress.tmpl b/internal/configs/version1/nginx-plus.ingress.tmpl index 4b1fd00913..5c941e3ace 100644 --- a/internal/configs/version1/nginx-plus.ingress.tmpl +++ b/internal/configs/version1/nginx-plus.ingress.tmpl @@ -179,7 +179,7 @@ server { {{range $location := $server.Locations}} location {{$location.Path}} { set $service "{{$location.ServiceName}}"; - status_zone "{{$location.ServiceName}}"; + status_zone "{{ $location.Path }}"; {{with $location.MinionIngress}} # location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}} set $resource_name "{{$location.MinionIngress.Name}}"; diff --git a/internal/configs/version2/nginx-plus.virtualserver.tmpl b/internal/configs/version2/nginx-plus.virtualserver.tmpl index 7334e171e9..12561a0683 100644 --- a/internal/configs/version2/nginx-plus.virtualserver.tmpl +++ b/internal/configs/version2/nginx-plus.virtualserver.tmpl @@ -337,7 +337,7 @@ server { {{ range $l := $s.Locations }} location {{ $l.Path }} { set $service "{{ $l.ServiceName }}"; - status_zone {{ $l.ServiceName }}; + status_zone "{{ $l.Path }}"; {{ if $l.IsVSR }} set $resource_type "virtualserverroute"; set $resource_name "{{ $l.VSRName }}"; From b8478a6ff0da0de60467787b0b67b7e00195be0b Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Mon, 10 Jul 2023 10:23:15 +0100 Subject: [PATCH 4/7] Use service names in the monitoring dashboard Dashboard and Prometheus metrics for locations (services) will be displayed under names of corresponding services. --- internal/configs/version1/nginx-plus.ingress.tmpl | 2 +- internal/configs/version2/nginx-plus.virtualserver.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/configs/version1/nginx-plus.ingress.tmpl b/internal/configs/version1/nginx-plus.ingress.tmpl index 5c941e3ace..2ceb881fec 100644 --- a/internal/configs/version1/nginx-plus.ingress.tmpl +++ b/internal/configs/version1/nginx-plus.ingress.tmpl @@ -179,7 +179,7 @@ server { {{range $location := $server.Locations}} location {{$location.Path}} { set $service "{{$location.ServiceName}}"; - status_zone "{{ $location.Path }}"; + status_zone "{{ $location.ServiceName }}"; {{with $location.MinionIngress}} # location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}} set $resource_name "{{$location.MinionIngress.Name}}"; diff --git a/internal/configs/version2/nginx-plus.virtualserver.tmpl b/internal/configs/version2/nginx-plus.virtualserver.tmpl index 12561a0683..2a958a53ff 100644 --- a/internal/configs/version2/nginx-plus.virtualserver.tmpl +++ b/internal/configs/version2/nginx-plus.virtualserver.tmpl @@ -337,7 +337,7 @@ server { {{ range $l := $s.Locations }} location {{ $l.Path }} { set $service "{{ $l.ServiceName }}"; - status_zone "{{ $l.Path }}"; + status_zone "{{ $l.ServiceName }}"; {{ if $l.IsVSR }} set $resource_type "virtualserverroute"; set $resource_name "{{ $l.VSRName }}"; From 95d52525d848a9d1ef0df1ed2df10a78d9cf85dc Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Mon, 10 Jul 2023 11:39:34 +0100 Subject: [PATCH 5/7] Update Logging and Metrics docs --- docs/content/logging-and-monitoring/prometheus.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/content/logging-and-monitoring/prometheus.md b/docs/content/logging-and-monitoring/prometheus.md index fe1dafe9e2..b3bb751f97 100644 --- a/docs/content/logging-and-monitoring/prometheus.md +++ b/docs/content/logging-and-monitoring/prometheus.md @@ -50,6 +50,13 @@ The Ingress Controller exports the following metrics: * `controller_ingress_resources_total`. Number of handled Ingress resources. This metric includes the label type, that groups the Ingress resources by their type (regular, [minion or master](/nginx-ingress-controller/configuration/ingress-resources/cross-namespace-configuration)). **Note**: The metric doesn't count minions without a master. * `controller_virtualserver_resources_total`. Number of handled VirtualServer resources. * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: The metric counts only VirtualServerRoutes that have a reference from a VirtualServer. + * `locatio_zone` (services) metrics: + * `location_zone_sent`. Number of bytes sent to clients. + * `location_zone_received`. Number of bytes received from clients. + * `location_zone_requests`. Total number of client requests. + * `location_zone_responses`. Total number of responses sent to clients. + * `location_zone_responses_codes`. Total number of responses sent to clients. + * `location_zone_sent`. Number of bytes sent to clients. * `controller_transportserver_resources_total`. Number of handled TransportServer resources. This metric includes the label type, that groups the TransportServer resources by their type (passthrough, tcp or udp). * Workqueue metrics. **Note**: the workqueue is a queue used by the Ingress Controller to process changes to the relevant resources in the cluster like Ingress resources. The Ingress Controller uses only one queue. The metrics for that queue will have the label `name="taskQueue"` * `workqueue_depth`. Current depth of the workqueue. From 084b6dfbb055174811fdf17f01e930718db59f4e Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Mon, 10 Jul 2023 12:49:09 +0100 Subject: [PATCH 6/7] Fix typo --- docs/content/logging-and-monitoring/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/logging-and-monitoring/prometheus.md b/docs/content/logging-and-monitoring/prometheus.md index b3bb751f97..1beb8d7a24 100644 --- a/docs/content/logging-and-monitoring/prometheus.md +++ b/docs/content/logging-and-monitoring/prometheus.md @@ -50,7 +50,7 @@ The Ingress Controller exports the following metrics: * `controller_ingress_resources_total`. Number of handled Ingress resources. This metric includes the label type, that groups the Ingress resources by their type (regular, [minion or master](/nginx-ingress-controller/configuration/ingress-resources/cross-namespace-configuration)). **Note**: The metric doesn't count minions without a master. * `controller_virtualserver_resources_total`. Number of handled VirtualServer resources. * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: The metric counts only VirtualServerRoutes that have a reference from a VirtualServer. - * `locatio_zone` (services) metrics: + * `location_zone` (services) metrics: * `location_zone_sent`. Number of bytes sent to clients. * `location_zone_received`. Number of bytes received from clients. * `location_zone_requests`. Total number of client requests. From 8f05fbad8c98ba5ee717a2b5d0041625763fb116 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Mon, 10 Jul 2023 14:22:54 +0100 Subject: [PATCH 7/7] Update docs --- docs/content/logging-and-monitoring/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/logging-and-monitoring/prometheus.md b/docs/content/logging-and-monitoring/prometheus.md index 1beb8d7a24..76eec64d48 100644 --- a/docs/content/logging-and-monitoring/prometheus.md +++ b/docs/content/logging-and-monitoring/prometheus.md @@ -50,7 +50,7 @@ The Ingress Controller exports the following metrics: * `controller_ingress_resources_total`. Number of handled Ingress resources. This metric includes the label type, that groups the Ingress resources by their type (regular, [minion or master](/nginx-ingress-controller/configuration/ingress-resources/cross-namespace-configuration)). **Note**: The metric doesn't count minions without a master. * `controller_virtualserver_resources_total`. Number of handled VirtualServer resources. * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: The metric counts only VirtualServerRoutes that have a reference from a VirtualServer. - * `location_zone` (services) metrics: + * `location_zone` (upstream services) metrics: * `location_zone_sent`. Number of bytes sent to clients. * `location_zone_received`. Number of bytes received from clients. * `location_zone_requests`. Total number of client requests.