From 3ee5161ccadf614a78547b85360ab472274fa3b6 Mon Sep 17 00:00:00 2001 From: Christian Hoffmeister Date: Fri, 31 May 2019 10:13:53 +0200 Subject: [PATCH] Always collect metrics when --metrics-per-host=false --- docs/user-guide/monitoring.md | 6 ++++++ internal/ingress/metric/collectors/socket.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/monitoring.md b/docs/user-guide/monitoring.md index ed5de73e7..a88d5b6ab 100644 --- a/docs/user-guide/monitoring.md +++ b/docs/user-guide/monitoring.md @@ -83,3 +83,9 @@ The username and password is `admin` After the login you can import the Grafana dashboard from _https://github.com/kubernetes/ingress-nginx/tree/master/deploy/grafana/dashboards_ ![Dashboard](../images/grafana.png) + +## Caveats + +### Wildcard ingresses + +By default request metrics are labeled with the hostname. When you have a wildcard domain ingress, then there will be no metrics for that ingress (to prevent the metrics from exploding in cardinality). To get metrics in this case you need to run the ingress controller with `--metrics-per-host=false` (you will loose labeling by hostname, but still have labeling by ingress). diff --git a/internal/ingress/metric/collectors/socket.go b/internal/ingress/metric/collectors/socket.go index 406a8b767..8c6113dfc 100644 --- a/internal/ingress/metric/collectors/socket.go +++ b/internal/ingress/metric/collectors/socket.go @@ -221,8 +221,8 @@ func (sc *SocketCollector) handleMessage(msg []byte) { } for _, stats := range statsBatch { - if !sc.hosts.Has(stats.Host) { - klog.V(3).Infof("skiping metric for host %v that is not being served", stats.Host) + if sc.metricsPerHost && !sc.hosts.Has(stats.Host) { + klog.V(3).Infof("Skipping metric for host %v that is not being served", stats.Host) continue }