From 20b64eb069255d1495304959c6e61eaf5c671b1f Mon Sep 17 00:00:00 2001 From: Tom Booth Date: Wed, 23 Aug 2017 18:11:35 +0100 Subject: [PATCH] Collect nginx metrics keyed by Ingress too Store the ingress resource that created a particular location so that we can then aggregate nginx metrics based on the ingress name too. --- controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl | 7 ++++++- core/pkg/ingress/controller/controller.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl index e51aedd36..c06554890 100644 --- a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl +++ b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl @@ -781,10 +781,15 @@ stream { proxy_set_header Accept-Encoding ""; {{ end }} - {{ if (and $all.Cfg.EnableVtsStatus $location.Service) }} + {{ if $all.Cfg.EnableVtsStatus }} + {{ if $location.Service }} vhost_traffic_status_filter_by_set_key {{ $location.Service.ObjectMeta.Namespace }} kubernetes::namespace; vhost_traffic_status_filter_by_set_key {{ $location.Service.ObjectMeta.Namespace }}.{{ $location.Service.ObjectMeta.Name }} kubernetes::service; {{ end }} + {{ if $location.Ingress }} + vhost_traffic_status_filter_by_set_key {{ $location.Ingress.ObjectMeta.Namespace }}.{{ $location.Ingress.ObjectMeta.Name }} kubernetes::ingress; + {{ end }} + {{ end }} {{/* Add any additional configuration defined */}} {{ $location.ConfigurationSnippet }} diff --git a/core/pkg/ingress/controller/controller.go b/core/pkg/ingress/controller/controller.go index 37df71a03..666b62f88 100644 --- a/core/pkg/ingress/controller/controller.go +++ b/core/pkg/ingress/controller/controller.go @@ -979,6 +979,7 @@ func (ic *GenericController) createServers(data []*extensions.Ingress, Backend: un, Proxy: ngxProxy, Service: &apiv1.Service{}, + Ingress: ing, }, }, SSLPassthrough: sslpt,