Skip to content

Commit

Permalink
WIP prometheus metrics: add pps in and out per service backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Murali Reddy committed Jul 19, 2017
1 parent 84e0357 commit ef66b01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ func (nrc *NetworkRoutingController) OnNodeUpdate(nodeUpdate *watchers.NodeUpdat
glog.Errorf("Failed to add node %s as peer due to %s", nodeIP, err)
}
activeNodes[nodeIP.String()] = true
nrc.disableSourceDestinationCheck()
} else if nodeUpdate.Op == watchers.REMOVE {
glog.Infof("Received node %s removed update from watch API, so remove node from peer", nodeIP)
n := &config.Neighbor{
Expand Down
18 changes: 17 additions & 1 deletion app/controllers/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
)

var (
h libipvs.IPVSHandle
h libipvs.IPVSHandle
serviceBackendActiveConn = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_backend_active_connections",
Expand All @@ -45,6 +45,16 @@ var (
Name: "service_backend_inactive_connections",
Help: "Active conntection to backend of service",
}, []string{"namespace", "service_name", "backend"})
serviceBackendPpsIn = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_backend_pps_in",
Help: "Incoming packets per second",
}, []string{"namespace", "service_name", "backend"})
serviceBackendPpsOut = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "service_backend_pps_out",
Help: "Outoging packets per second",
}, []string{"namespace", "service_name", "backend"})
)

// Network services controller enables local node as network service proxy through IPVS/LVS.
Expand Down Expand Up @@ -109,6 +119,8 @@ func (nsc *NetworkServicesController) Run(stopCh <-chan struct{}, wg *sync.WaitG
// register metrics
prometheus.MustRegister(serviceBackendActiveConn)
prometheus.MustRegister(serviceBackendInactiveConn)
prometheus.MustRegister(serviceBackendPpsIn)
prometheus.MustRegister(serviceBackendPpsOut)
http.Handle("/metrics", promhttp.Handler())
go http.ListenAndServe(":8080", nil)

Expand Down Expand Up @@ -348,6 +360,8 @@ func (nsc *NetworkServicesController) publishMetrics(serviceInfoMap serviceInfoM
for _, dst := range dsts {
serviceBackendActiveConn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.ActiveConns))
serviceBackendInactiveConn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.InactConns))
serviceBackendPpsIn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.Stats.PPSIn))
serviceBackendPpsOut.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.Stats.PPSOut))
}
}
if strings.Compare(nsc.nodeIP.String(), ipvsSvc.Address.String()) == 0 &&
Expand All @@ -359,6 +373,8 @@ func (nsc *NetworkServicesController) publishMetrics(serviceInfoMap serviceInfoM
for _, dst := range dsts {
serviceBackendActiveConn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.ActiveConns))
serviceBackendInactiveConn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.InactConns))
serviceBackendPpsIn.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.Stats.PPSIn))
serviceBackendPpsOut.WithLabelValues(svc.namespace, svc.name, dst.Address.String()).Set(float64(dst.Stats.PPSOut))
}
}
}
Expand Down

0 comments on commit ef66b01

Please sign in to comment.