Add new prometheus metric for orphaned ingress (#8230)
* Add new metric for orhaned ingress * Fix const labels * Fix after rebase
This commit is contained in:
parent
dbe88c55a3
commit
39b5ce844b
5 changed files with 67 additions and 7 deletions
|
|
@ -50,10 +50,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
defUpstreamName = "upstream-default-backend"
|
||||
defServerName = "_"
|
||||
rootLocation = "/"
|
||||
emptyZone = ""
|
||||
defUpstreamName = "upstream-default-backend"
|
||||
defServerName = "_"
|
||||
rootLocation = "/"
|
||||
emptyZone = ""
|
||||
orphanMetricLabelNoService = "no-service"
|
||||
orphanMetricLabelNoEndpoint = "no-endpoint"
|
||||
)
|
||||
|
||||
// Configuration contains all the settings required by an Ingress controller
|
||||
|
|
@ -1052,8 +1054,16 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
endp, err := n.serviceEndpoints(svcKey, port.String())
|
||||
if err != nil {
|
||||
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||
n.metricCollector.IncOrphanIngress(ing.Namespace, ing.Name, orphanMetricLabelNoService)
|
||||
continue
|
||||
}
|
||||
n.metricCollector.DecOrphanIngress(ing.Namespace, ing.Name, orphanMetricLabelNoService)
|
||||
|
||||
if len(endp) == 0 {
|
||||
n.metricCollector.IncOrphanIngress(ing.Namespace, ing.Name, orphanMetricLabelNoEndpoint)
|
||||
} else {
|
||||
n.metricCollector.DecOrphanIngress(ing.Namespace, ing.Name, orphanMetricLabelNoEndpoint)
|
||||
}
|
||||
upstreams[name].Endpoints = endp
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue