From 4bfe9aadc63801dc79803bd95d68bbda0268ce0b Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Fri, 11 Oct 2019 15:28:19 +0100 Subject: [PATCH 1/7] Add VS/VSR Prometheus metrics --- docs/prometheus.md | 2 + internal/k8s/controller.go | 12 +++++ internal/metrics/collectors/controller.go | 64 +++++++++++++++++++---- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/docs/prometheus.md b/docs/prometheus.md index 88ab0ff629..daee092d0f 100644 --- a/docs/prometheus.md +++ b/docs/prometheus.md @@ -16,5 +16,7 @@ The Ingress Controller exports the following metrics: * `controller_nginx_last_reload_status`. Status of the last NGINX reload, 0 meaning down and 1 up. * `controller_nginx_last_reload_milliseconds`. Duration in milliseconds of the last NGINX reload. * `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](./../examples/mergeable-ingress-types)) + * `controller_virtualserver_resources_total`. Number of handled VirtualServer resources. + * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: all metrics have the namespace nginx_ingress. For example, nginx_ingress_controller_nginx_reloads_total. diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index 11ecc43c70..a7792ecdcb 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -605,8 +605,10 @@ func (lbc *LoadBalancerController) sync(task task) { lbc.syncExternalService(task) case virtualserver: lbc.syncVirtualServer(task) + lbc.updateVsMetrics() case virtualServerRoute: lbc.syncVirtualServerRoute(task) + lbc.updateVsrMetrics() } } @@ -851,6 +853,16 @@ func (lbc *LoadBalancerController) updateIngressMetrics() { } } +func (lbc *LoadBalancerController) updateVsMetrics() { + count := len(lbc.getVirtualServers()) + lbc.metricsCollector.SetVsResources(count) +} + +func (lbc *LoadBalancerController) updateVsrMetrics() { + count := len(lbc.getVirtualServerRoutes()) + lbc.metricsCollector.SetVsrResources(count) +} + // syncExternalService does not sync all services. // We only watch the Service specified by the external-service flag. func (lbc *LoadBalancerController) syncExternalService(task task) { diff --git a/internal/metrics/collectors/controller.go b/internal/metrics/collectors/controller.go index 52a68da448..10c5e9bc2c 100644 --- a/internal/metrics/collectors/controller.go +++ b/internal/metrics/collectors/controller.go @@ -7,28 +7,50 @@ var labelNamesController = []string{"type"} // ControllerCollector is an interface for the metrics of the Controller type ControllerCollector interface { SetIngressResources(ingressType string, count int) + SetVsResources(count int) + SetVsrResources(count int) Register(registry *prometheus.Registry) error } // ControllerMetricsCollector implements the ControllerCollector interface and prometheus.Collector interface type ControllerMetricsCollector struct { ingressResourcesTotal *prometheus.GaugeVec + vsResourcesTotal prometheus.Gauge + vsrResourcesTotal prometheus.Gauge } // NewControllerMetricsCollector creates a new ControllerMetricsCollector func NewControllerMetricsCollector() *ControllerMetricsCollector { - cc := &ControllerMetricsCollector{ - ingressResourcesTotal: prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "ingress_resources_total", - Namespace: metricsNamespace, - Help: "Number of handled ingress resources", - }, - labelNamesController, - ), - } + ingResTotal := prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "ingress_resources_total", + Namespace: metricsNamespace, + Help: "Number of handled ingress resources", + }, + labelNamesController, + ) + + vsResTotal := prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "virtualserver_resources_total", + Namespace: metricsNamespace, + Help: "Number of handled VirtualServer resources", + }, + ) + + vsrResTotal := prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "virtualserverroute_resources_total", + Namespace: metricsNamespace, + Help: "Number of handled VirtualServerRoute resources", + }, + ) - return cc + return &ControllerMetricsCollector{ + ingressResourcesTotal: ingResTotal, + vsResourcesTotal: vsResTotal, + vsrResourcesTotal: vsrResTotal, + } } // SetIngressResources sets the value of the ingress resources gauge for a given type @@ -36,14 +58,28 @@ func (cc *ControllerMetricsCollector) SetIngressResources(ingressType string, co cc.ingressResourcesTotal.WithLabelValues(ingressType).Set(float64(count)) } +// SetVsResources sets the value of the VS resources gauge for a given type +func (cc *ControllerMetricsCollector) SetVsResources(count int) { + cc.vsResourcesTotal.Set(float64(count)) +} + +// SetVsrResources sets the value of the VSR resources gauge for a given type +func (cc *ControllerMetricsCollector) SetVsrResources(count int) { + cc.vsrResourcesTotal.Set(float64(count)) +} + // Describe implements prometheus.Collector interface Describe method func (cc *ControllerMetricsCollector) Describe(ch chan<- *prometheus.Desc) { cc.ingressResourcesTotal.Describe(ch) + cc.vsResourcesTotal.Describe(ch) + cc.vsrResourcesTotal.Describe(ch) } // Collect implements the prometheus.Collector interface Collect method func (cc *ControllerMetricsCollector) Collect(ch chan<- prometheus.Metric) { cc.ingressResourcesTotal.Collect(ch) + cc.vsResourcesTotal.Collect(ch) + cc.vsrResourcesTotal.Collect(ch) } // Register registers all the metrics of the collector @@ -64,3 +100,9 @@ func (cc *ControllerFakeCollector) Register(registry *prometheus.Registry) error // SetIngressResources implements a fake SetIngressResources func (cc *ControllerFakeCollector) SetIngressResources(ingressType string, count int) {} + +// SetVsResources implements a fake SetVsResources +func (cc *ControllerFakeCollector) SetVsResources(count int) {} + +// SetVsrResources implements a fake SetVsrResources +func (cc *ControllerFakeCollector) SetVsrResources(count int) {} From ecb479cd8f6c2ae1e9bc1e991e14cede6ed87173 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 15 Oct 2019 10:43:13 +0100 Subject: [PATCH 2/7] Only report VS/VSRs handled by the Controller --- internal/configs/configurator.go | 18 ++++++++++++++++++ internal/k8s/controller.go | 12 ++++-------- internal/metrics/collectors/controller.go | 4 ++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/internal/configs/configurator.go b/internal/configs/configurator.go index 8c9ffea389..f7bac2cf38 100644 --- a/internal/configs/configurator.go +++ b/internal/configs/configurator.go @@ -37,6 +37,7 @@ type Configurator struct { templateExecutorV2 *version2.TemplateExecutor ingresses map[string]*IngressEx minions map[string]map[string]bool + virtualServers map[string]*VirtualServerEx isWildcardEnabled bool isPlus bool } @@ -49,6 +50,7 @@ func NewConfigurator(nginxManager nginx.Manager, staticCfgParams *StaticConfigPa staticCfgParams: staticCfgParams, cfgParams: config, ingresses: make(map[string]*IngressEx), + virtualServers: make(map[string]*VirtualServerEx), templateExecutor: templateExecutor, templateExecutorV2: templateExecutorV2, minions: make(map[string]map[string]bool), @@ -170,6 +172,8 @@ func (cnf *Configurator) addOrUpdateVirtualServer(virtualServerEx *VirtualServer } cnf.nginxManager.CreateConfig(name, content) + cnf.virtualServers[name] = virtualServerEx + return warnings, nil } @@ -339,6 +343,8 @@ func (cnf *Configurator) DeleteVirtualServer(key string) error { name := getFileNameForVirtualServerFromKey(key) cnf.nginxManager.DeleteConfig(name) + delete(cnf.virtualServers, name) + if err := cnf.nginxManager.Reload(); err != nil { return fmt.Errorf("Error when removing VirtualServer %v: %v", key, err) } @@ -637,3 +643,15 @@ func (cnf *Configurator) GetIngressCounts() map[string]int { return counters } + +// GetVSCounts returns the total count of Vs/Vsr resources that are handled by the Ingress Controller +func (cnf *Configurator) GetVSCounts() (vsCount int, vsrCount int) { + for _, vs := range cnf.virtualServers { + if vs != nil { + vsCount++ + } + vsrCount += len(vs.VirtualServerRoutes) + } + + return vsCount, vsrCount +} diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index a7792ecdcb..26d84276b9 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -608,7 +608,7 @@ func (lbc *LoadBalancerController) sync(task task) { lbc.updateVsMetrics() case virtualServerRoute: lbc.syncVirtualServerRoute(task) - lbc.updateVsrMetrics() + lbc.updateVsMetrics() } } @@ -854,13 +854,9 @@ func (lbc *LoadBalancerController) updateIngressMetrics() { } func (lbc *LoadBalancerController) updateVsMetrics() { - count := len(lbc.getVirtualServers()) - lbc.metricsCollector.SetVsResources(count) -} - -func (lbc *LoadBalancerController) updateVsrMetrics() { - count := len(lbc.getVirtualServerRoutes()) - lbc.metricsCollector.SetVsrResources(count) + vsCount, vsrCount := lbc.configurator.GetVSCounts() + lbc.metricsCollector.SetVsResources(vsCount) + lbc.metricsCollector.SetVsrResources(vsrCount) } // syncExternalService does not sync all services. diff --git a/internal/metrics/collectors/controller.go b/internal/metrics/collectors/controller.go index 10c5e9bc2c..dbd6157219 100644 --- a/internal/metrics/collectors/controller.go +++ b/internal/metrics/collectors/controller.go @@ -58,12 +58,12 @@ func (cc *ControllerMetricsCollector) SetIngressResources(ingressType string, co cc.ingressResourcesTotal.WithLabelValues(ingressType).Set(float64(count)) } -// SetVsResources sets the value of the VS resources gauge for a given type +// SetVsResources sets the value of the VS resources gauge func (cc *ControllerMetricsCollector) SetVsResources(count int) { cc.vsResourcesTotal.Set(float64(count)) } -// SetVsrResources sets the value of the VSR resources gauge for a given type +// SetVsrResources sets the value of the VSR resources gauge func (cc *ControllerMetricsCollector) SetVsrResources(count int) { cc.vsrResourcesTotal.Set(float64(count)) } From 656d0b30035794b9eec0adc378dde8fdd1a908fe Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 15 Oct 2019 11:40:49 +0100 Subject: [PATCH 3/7] Remove redundant nil check --- internal/configs/configurator.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/configs/configurator.go b/internal/configs/configurator.go index f7bac2cf38..0e57b2ee11 100644 --- a/internal/configs/configurator.go +++ b/internal/configs/configurator.go @@ -646,10 +646,8 @@ func (cnf *Configurator) GetIngressCounts() map[string]int { // GetVSCounts returns the total count of Vs/Vsr resources that are handled by the Ingress Controller func (cnf *Configurator) GetVSCounts() (vsCount int, vsrCount int) { + vsCount = len(cnf.virtualServers) for _, vs := range cnf.virtualServers { - if vs != nil { - vsCount++ - } vsrCount += len(vs.VirtualServerRoutes) } From 78e3b6d264086e8c11b66da9a6e6d7fc34ef5cb9 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Tue, 15 Oct 2019 16:03:00 +0100 Subject: [PATCH 4/7] Add note about vsr metrics --- docs/prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/prometheus.md b/docs/prometheus.md index daee092d0f..80d026608b 100644 --- a/docs/prometheus.md +++ b/docs/prometheus.md @@ -17,6 +17,6 @@ The Ingress Controller exports the following metrics: * `controller_nginx_last_reload_milliseconds`. Duration in milliseconds of the last NGINX reload. * `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](./../examples/mergeable-ingress-types)) * `controller_virtualserver_resources_total`. Number of handled VirtualServer resources. - * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. + * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: Only counts VirtualServerRoutes that have a reference from a VirtualServer. **Note**: all metrics have the namespace nginx_ingress. For example, nginx_ingress_controller_nginx_reloads_total. From 0dc08edd1d30263ad7d7de5dabd131f4e7de8762 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Wed, 16 Oct 2019 10:36:18 +0100 Subject: [PATCH 5/7] Add minions note. Improve variable names --- docs/prometheus.md | 4 +- internal/configs/configurator.go | 4 +- internal/k8s/controller.go | 14 +++--- internal/metrics/collectors/controller.go | 60 +++++++++++------------ 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/docs/prometheus.md b/docs/prometheus.md index 80d026608b..dc2c5339a1 100644 --- a/docs/prometheus.md +++ b/docs/prometheus.md @@ -15,8 +15,8 @@ The Ingress Controller exports the following metrics: * `controller_nginx_reload_errors_total`. Number of unsuccessful NGINX reloads. * `controller_nginx_last_reload_status`. Status of the last NGINX reload, 0 meaning down and 1 up. * `controller_nginx_last_reload_milliseconds`. Duration in milliseconds of the last NGINX reload. - * `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](./../examples/mergeable-ingress-types)) + * `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](./../examples/mergeable-ingress-types)). **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**: Only counts VirtualServerRoutes that have a reference from a VirtualServer. + * `controller_virtualserverroute_resources_total`. Number of handled VirtualServerRoute resources. **Note**: The metric counts only VirtualServerRoutes that have a reference from a VirtualServer. **Note**: all metrics have the namespace nginx_ingress. For example, nginx_ingress_controller_nginx_reloads_total. diff --git a/internal/configs/configurator.go b/internal/configs/configurator.go index 0e57b2ee11..8151b8118f 100644 --- a/internal/configs/configurator.go +++ b/internal/configs/configurator.go @@ -644,8 +644,8 @@ func (cnf *Configurator) GetIngressCounts() map[string]int { return counters } -// GetVSCounts returns the total count of Vs/Vsr resources that are handled by the Ingress Controller -func (cnf *Configurator) GetVSCounts() (vsCount int, vsrCount int) { +// GetVirtualServerCounts returns the total count of VS/VSR resources that are handled by the Ingress Controller +func (cnf *Configurator) GetVirtualServerCounts() (vsCount int, vsrCount int) { vsCount = len(cnf.virtualServers) for _, vs := range cnf.virtualServers { vsrCount += len(vs.VirtualServerRoutes) diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index 26d84276b9..0346250af9 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -605,10 +605,10 @@ func (lbc *LoadBalancerController) sync(task task) { lbc.syncExternalService(task) case virtualserver: lbc.syncVirtualServer(task) - lbc.updateVsMetrics() + lbc.updateVirtualServerMetrics() case virtualServerRoute: lbc.syncVirtualServerRoute(task) - lbc.updateVsMetrics() + lbc.updateVirtualServerMetrics() } } @@ -849,14 +849,14 @@ func (lbc *LoadBalancerController) syncIng(task task) { func (lbc *LoadBalancerController) updateIngressMetrics() { counters := lbc.configurator.GetIngressCounts() for nType, count := range counters { - lbc.metricsCollector.SetIngressResources(nType, count) + lbc.metricsCollector.SetIngress(nType, count) } } -func (lbc *LoadBalancerController) updateVsMetrics() { - vsCount, vsrCount := lbc.configurator.GetVSCounts() - lbc.metricsCollector.SetVsResources(vsCount) - lbc.metricsCollector.SetVsrResources(vsrCount) +func (lbc *LoadBalancerController) updateVirtualServerMetrics() { + vsCount, vsrCount := lbc.configurator.GetVirtualServerCounts() + lbc.metricsCollector.SetVirtualServer(vsCount) + lbc.metricsCollector.SetVirtualServerRoute(vsrCount) } // syncExternalService does not sync all services. diff --git a/internal/metrics/collectors/controller.go b/internal/metrics/collectors/controller.go index dbd6157219..36e6505d98 100644 --- a/internal/metrics/collectors/controller.go +++ b/internal/metrics/collectors/controller.go @@ -6,17 +6,17 @@ var labelNamesController = []string{"type"} // ControllerCollector is an interface for the metrics of the Controller type ControllerCollector interface { - SetIngressResources(ingressType string, count int) - SetVsResources(count int) - SetVsrResources(count int) + SetIngress(ingressType string, count int) + SetVirtualServer(count int) + SetVirtualServerRoute(count int) Register(registry *prometheus.Registry) error } // ControllerMetricsCollector implements the ControllerCollector interface and prometheus.Collector interface type ControllerMetricsCollector struct { - ingressResourcesTotal *prometheus.GaugeVec - vsResourcesTotal prometheus.Gauge - vsrResourcesTotal prometheus.Gauge + ingressesTotal *prometheus.GaugeVec + virtualServersTotal prometheus.Gauge + virtualServerRoutesTotal prometheus.Gauge } // NewControllerMetricsCollector creates a new ControllerMetricsCollector @@ -47,39 +47,39 @@ func NewControllerMetricsCollector() *ControllerMetricsCollector { ) return &ControllerMetricsCollector{ - ingressResourcesTotal: ingResTotal, - vsResourcesTotal: vsResTotal, - vsrResourcesTotal: vsrResTotal, + ingressesTotal: ingResTotal, + virtualServersTotal: vsResTotal, + virtualServerRoutesTotal: vsrResTotal, } } -// SetIngressResources sets the value of the ingress resources gauge for a given type -func (cc *ControllerMetricsCollector) SetIngressResources(ingressType string, count int) { - cc.ingressResourcesTotal.WithLabelValues(ingressType).Set(float64(count)) +// SetIngress sets the value of the ingress resources gauge for a given type +func (cc *ControllerMetricsCollector) SetIngress(ingressType string, count int) { + cc.ingressesTotal.WithLabelValues(ingressType).Set(float64(count)) } -// SetVsResources sets the value of the VS resources gauge -func (cc *ControllerMetricsCollector) SetVsResources(count int) { - cc.vsResourcesTotal.Set(float64(count)) +// SetVirtualServer sets the value of the VirtualServer resources gauge +func (cc *ControllerMetricsCollector) SetVirtualServer(count int) { + cc.virtualServersTotal.Set(float64(count)) } -// SetVsrResources sets the value of the VSR resources gauge -func (cc *ControllerMetricsCollector) SetVsrResources(count int) { - cc.vsrResourcesTotal.Set(float64(count)) +// SetVirtualServerRoute sets the value of the VirtualServerRoute resources gauge +func (cc *ControllerMetricsCollector) SetVirtualServerRoute(count int) { + cc.virtualServerRoutesTotal.Set(float64(count)) } // Describe implements prometheus.Collector interface Describe method func (cc *ControllerMetricsCollector) Describe(ch chan<- *prometheus.Desc) { - cc.ingressResourcesTotal.Describe(ch) - cc.vsResourcesTotal.Describe(ch) - cc.vsrResourcesTotal.Describe(ch) + cc.ingressesTotal.Describe(ch) + cc.virtualServersTotal.Describe(ch) + cc.virtualServerRoutesTotal.Describe(ch) } // Collect implements the prometheus.Collector interface Collect method func (cc *ControllerMetricsCollector) Collect(ch chan<- prometheus.Metric) { - cc.ingressResourcesTotal.Collect(ch) - cc.vsResourcesTotal.Collect(ch) - cc.vsrResourcesTotal.Collect(ch) + cc.ingressesTotal.Collect(ch) + cc.virtualServersTotal.Collect(ch) + cc.virtualServerRoutesTotal.Collect(ch) } // Register registers all the metrics of the collector @@ -98,11 +98,11 @@ func NewControllerFakeCollector() *ControllerFakeCollector { // Register implements a fake Register func (cc *ControllerFakeCollector) Register(registry *prometheus.Registry) error { return nil } -// SetIngressResources implements a fake SetIngressResources -func (cc *ControllerFakeCollector) SetIngressResources(ingressType string, count int) {} +// SetIngress implements a fake SetIngress +func (cc *ControllerFakeCollector) SetIngress(ingressType string, count int) {} -// SetVsResources implements a fake SetVsResources -func (cc *ControllerFakeCollector) SetVsResources(count int) {} +// SetVirtualServer implements a fake SetVirtualServer +func (cc *ControllerFakeCollector) SetVirtualServer(count int) {} -// SetVsrResources implements a fake SetVsrResources -func (cc *ControllerFakeCollector) SetVsrResources(count int) {} +// SetVirtualServerRoute implements a fake SetVirtualServerRoute +func (cc *ControllerFakeCollector) SetVirtualServerRoute(count int) {} From 019a4a6f113f23c0d622812c12b5aa883825c81a Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Thu, 17 Oct 2019 09:06:55 +0100 Subject: [PATCH 6/7] Make set methods plural --- internal/k8s/controller.go | 6 ++--- internal/metrics/collectors/controller.go | 30 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/k8s/controller.go b/internal/k8s/controller.go index 0346250af9..82c3ae36d0 100644 --- a/internal/k8s/controller.go +++ b/internal/k8s/controller.go @@ -849,14 +849,14 @@ func (lbc *LoadBalancerController) syncIng(task task) { func (lbc *LoadBalancerController) updateIngressMetrics() { counters := lbc.configurator.GetIngressCounts() for nType, count := range counters { - lbc.metricsCollector.SetIngress(nType, count) + lbc.metricsCollector.SetIngresses(nType, count) } } func (lbc *LoadBalancerController) updateVirtualServerMetrics() { vsCount, vsrCount := lbc.configurator.GetVirtualServerCounts() - lbc.metricsCollector.SetVirtualServer(vsCount) - lbc.metricsCollector.SetVirtualServerRoute(vsrCount) + lbc.metricsCollector.SetVirtualServers(vsCount) + lbc.metricsCollector.SetVirtualServerRoutes(vsrCount) } // syncExternalService does not sync all services. diff --git a/internal/metrics/collectors/controller.go b/internal/metrics/collectors/controller.go index 36e6505d98..8749409994 100644 --- a/internal/metrics/collectors/controller.go +++ b/internal/metrics/collectors/controller.go @@ -6,9 +6,9 @@ var labelNamesController = []string{"type"} // ControllerCollector is an interface for the metrics of the Controller type ControllerCollector interface { - SetIngress(ingressType string, count int) - SetVirtualServer(count int) - SetVirtualServerRoute(count int) + SetIngresses(ingressType string, count int) + SetVirtualServers(count int) + SetVirtualServerRoutes(count int) Register(registry *prometheus.Registry) error } @@ -53,18 +53,18 @@ func NewControllerMetricsCollector() *ControllerMetricsCollector { } } -// SetIngress sets the value of the ingress resources gauge for a given type -func (cc *ControllerMetricsCollector) SetIngress(ingressType string, count int) { +// SetIngresses sets the value of the ingress resources gauge for a given type +func (cc *ControllerMetricsCollector) SetIngresses(ingressType string, count int) { cc.ingressesTotal.WithLabelValues(ingressType).Set(float64(count)) } -// SetVirtualServer sets the value of the VirtualServer resources gauge -func (cc *ControllerMetricsCollector) SetVirtualServer(count int) { +// SetVirtualServers sets the value of the VirtualServer resources gauge +func (cc *ControllerMetricsCollector) SetVirtualServers(count int) { cc.virtualServersTotal.Set(float64(count)) } -// SetVirtualServerRoute sets the value of the VirtualServerRoute resources gauge -func (cc *ControllerMetricsCollector) SetVirtualServerRoute(count int) { +// SetVirtualServerRoutes sets the value of the VirtualServerRoute resources gauge +func (cc *ControllerMetricsCollector) SetVirtualServerRoutes(count int) { cc.virtualServerRoutesTotal.Set(float64(count)) } @@ -98,11 +98,11 @@ func NewControllerFakeCollector() *ControllerFakeCollector { // Register implements a fake Register func (cc *ControllerFakeCollector) Register(registry *prometheus.Registry) error { return nil } -// SetIngress implements a fake SetIngress -func (cc *ControllerFakeCollector) SetIngress(ingressType string, count int) {} +// SetIngresses implements a fake SetIngress +func (cc *ControllerFakeCollector) SetIngresses(ingressType string, count int) {} -// SetVirtualServer implements a fake SetVirtualServer -func (cc *ControllerFakeCollector) SetVirtualServer(count int) {} +// SetVirtualServers implements a fake SetVirtualServers +func (cc *ControllerFakeCollector) SetVirtualServers(count int) {} -// SetVirtualServerRoute implements a fake SetVirtualServerRoute -func (cc *ControllerFakeCollector) SetVirtualServerRoute(count int) {} +// SetVirtualServerRoutes implements a fake SetVirtualServerRoutes +func (cc *ControllerFakeCollector) SetVirtualServerRoutes(count int) {} From 892de880da3efa571e317d4265353d2059ec605f Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Thu, 17 Oct 2019 09:09:43 +0100 Subject: [PATCH 7/7] Typo --- internal/metrics/collectors/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/metrics/collectors/controller.go b/internal/metrics/collectors/controller.go index 8749409994..d94688be97 100644 --- a/internal/metrics/collectors/controller.go +++ b/internal/metrics/collectors/controller.go @@ -98,7 +98,7 @@ func NewControllerFakeCollector() *ControllerFakeCollector { // Register implements a fake Register func (cc *ControllerFakeCollector) Register(registry *prometheus.Registry) error { return nil } -// SetIngresses implements a fake SetIngress +// SetIngresses implements a fake SetIngresses func (cc *ControllerFakeCollector) SetIngresses(ingressType string, count int) {} // SetVirtualServers implements a fake SetVirtualServers