@@ -49,17 +49,17 @@ var (
4949 Namespace : namespace ,
5050 Name : "service_active_connections" ,
5151 Help : "Active conntection to service" ,
52- }, []string {"namespace" , "service_name" , "backend " })
52+ }, []string {"namespace" , "service_name" , "service_vip " })
5353 servicePpsIn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
5454 Namespace : namespace ,
5555 Name : "service_pps_in" ,
5656 Help : "Incoming packets per second" ,
57- }, []string {"namespace" , "service_name" })
57+ }, []string {"namespace" , "service_name" , "service_vip" })
5858 servicePpsOut = prometheus .NewGaugeVec (prometheus.GaugeOpts {
5959 Namespace : namespace ,
6060 Name : "service_pps_out" ,
6161 Help : "Outoging packets per second" ,
62- }, []string {"namespace" , "service_name" })
62+ }, []string {"namespace" , "service_name" , "service_vip" })
6363)
6464
6565// NetworkServicesController enables local node as network service proxy through IPVS/LVS.
@@ -679,15 +679,23 @@ func (nsc *NetworkServicesController) publishMetrics(serviceInfoMap serviceInfoM
679679 }
680680
681681 for _ , svc := range serviceInfoMap {
682+ var protocol uint16
683+ if svc .protocol == "tcp" {
684+ protocol = syscall .IPPROTO_TCP
685+ } else {
686+ protocol = syscall .IPPROTO_UDP
687+ }
682688 for _ , ipvsSvc := range ipvsSvcs {
683689 if strings .Compare (svc .clusterIP .String (), ipvsSvc .Address .String ()) == 0 &&
684- svc .protocol == strconv .Itoa (int (ipvsSvc .Protocol )) && uint16 (svc .port ) == ipvsSvc .Port {
690+ protocol == ipvsSvc .Protocol && uint16 (svc .port ) == ipvsSvc .Port {
691+ glog .Infof ("Publishing prometheus metrics " + svc .clusterIP .String () + ":" + strconv .Itoa (svc .port ))
685692 serviceActiveConn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
686693 servicePpsIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
687694 servicePpsOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
688695 }
689696 if strings .Compare (nsc .nodeIP .String (), ipvsSvc .Address .String ()) == 0 &&
690- svc .protocol == strconv .Itoa (int (ipvsSvc .Protocol )) && uint16 (svc .port ) == ipvsSvc .Port {
697+ protocol == ipvsSvc .Protocol && uint16 (svc .port ) == ipvsSvc .Port {
698+ glog .Infof ("Publishing prometheus metrics " + nsc .nodeIP .String () + ":" + strconv .Itoa (svc .port ))
691699 serviceActiveConn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
692700 servicePpsIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
693701 servicePpsOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
0 commit comments