Commit ad6cd3bc authored by Geoff Simmons's avatar Geoff Simmons

Add the backend_services and backend_endpoints gauges.

parent 1ff7b034
......@@ -76,6 +76,22 @@ var (
Help: "Current number of known admin secrets",
})
beSvcsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "backend_services",
Help: "Current number of Services configured as Varnish " +
"backends",
})
beEndpsGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "backend_endpoints",
Help: "Current number of Service endpoints configured " +
"as Varnish backends",
})
monResultCtr = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
......@@ -100,6 +116,8 @@ func initMetrics() {
prometheus.Register(instsGauge)
prometheus.Register(secretsGauge)
prometheus.Register(monResultCtr)
prometheus.Register(beSvcsGauge)
prometheus.Register(beEndpsGauge)
}
func getInstanceMetrics(addr string) *instanceMetrics {
......
......@@ -546,6 +546,19 @@ func (vc *VarnishController) DeleteVarnishSvc(key string) error {
return err
}
func (vc *VarnishController) updateBeGauges() {
nBeSvcs := 0
nBeEndps := 0
for _, svc := range vc.svcs {
nBeSvcs += len(svc.spec.spec.AllServices)
for _, beSvc := range svc.spec.spec.AllServices {
nBeEndps += len(beSvc.Addresses)
}
}
beSvcsGauge.Set(float64(nBeSvcs))
beEndpsGauge.Set(float64(nBeEndps))
}
// Update a Varnish Service to implement an Ingress.
//
// svcKey: namespace/name key for the Service
......@@ -570,6 +583,7 @@ func (vc *VarnishController) Update(
svc.spec.key = ingKey
svc.spec.uid = uid
svc.spec.spec = spec
vc.updateBeGauges()
if len(svc.instances) == 0 {
return fmt.Errorf("Ingress %s uid=%s: Currently no known "+
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment