@@ -45,11 +45,31 @@ const (
4545)
4646
4747var (
48- h * ipvs.Handle
49- serviceActiveConn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
48+ h * ipvs.Handle
49+ serviceTotalConn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
5050 Namespace : namespace ,
51- Name : "service_active_connections" ,
52- Help : "Active conntection to service" ,
51+ Name : "service_total_connections" ,
52+ Help : "Total conntection to service" ,
53+ }, []string {"namespace" , "service_name" , "service_vip" })
54+ servicePacketsIn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
55+ Namespace : namespace ,
56+ Name : "service_packets_in" ,
57+ Help : "Total incoming packets" ,
58+ }, []string {"namespace" , "service_name" , "service_vip" })
59+ servicePacketsOut = prometheus .NewGaugeVec (prometheus.GaugeOpts {
60+ Namespace : namespace ,
61+ Name : "service_packets_out" ,
62+ Help : "Total outoging packets" ,
63+ }, []string {"namespace" , "service_name" , "service_vip" })
64+ serviceBytesIn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
65+ Namespace : namespace ,
66+ Name : "service_bytes_in" ,
67+ Help : "Total incoming bytes" ,
68+ }, []string {"namespace" , "service_name" , "service_vip" })
69+ serviceBytesOut = prometheus .NewGaugeVec (prometheus.GaugeOpts {
70+ Namespace : namespace ,
71+ Name : "service_bytes_out" ,
72+ Help : "Total outoging bytes" ,
5373 }, []string {"namespace" , "service_name" , "service_vip" })
5474 servicePpsIn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
5575 Namespace : namespace ,
6181 Name : "service_pps_out" ,
6282 Help : "Outoging packets per second" ,
6383 }, []string {"namespace" , "service_name" , "service_vip" })
84+ serviceCPS = prometheus .NewGaugeVec (prometheus.GaugeOpts {
85+ Namespace : namespace ,
86+ Name : "service_cps" ,
87+ Help : "Service connections per second" ,
88+ }, []string {"namespace" , "service_name" , "service_vip" })
89+ serviceBpsIn = prometheus .NewGaugeVec (prometheus.GaugeOpts {
90+ Namespace : namespace ,
91+ Name : "service_bps_in" ,
92+ Help : "Incoming bytes per second" ,
93+ }, []string {"namespace" , "service_name" , "service_vip" })
94+ serviceBpsOut = prometheus .NewGaugeVec (prometheus.GaugeOpts {
95+ Namespace : namespace ,
96+ Name : "service_bps_out" ,
97+ Help : "Outoging bytes per second" ,
98+ }, []string {"namespace" , "service_name" , "service_vip" })
6499)
65100
66101// NetworkServicesController enables local node as network service proxy through IPVS/LVS.
@@ -132,9 +167,17 @@ func (nsc *NetworkServicesController) Run(stopCh <-chan struct{}, wg *sync.WaitG
132167 }
133168
134169 // register metrics
135- prometheus .MustRegister (serviceActiveConn )
170+ prometheus .MustRegister (serviceBpsIn )
171+ prometheus .MustRegister (serviceBpsOut )
172+ prometheus .MustRegister (serviceBytesIn )
173+ prometheus .MustRegister (serviceBytesOut )
174+ prometheus .MustRegister (serviceCPS )
175+ prometheus .MustRegister (servicePacketsIn )
176+ prometheus .MustRegister (servicePacketsOut )
136177 prometheus .MustRegister (servicePpsIn )
137178 prometheus .MustRegister (servicePpsOut )
179+ prometheus .MustRegister (serviceTotalConn )
180+
138181 http .Handle (nsc .MetricsPath , promhttp .Handler ())
139182 go http .ListenAndServe (":" + strconv .Itoa (nsc .MetricsPort ), nil )
140183
@@ -748,16 +791,31 @@ func (nsc *NetworkServicesController) publishMetrics(serviceInfoMap serviceInfoM
748791 if strings .Compare (svc .clusterIP .String (), ipvsSvc .Address .String ()) == 0 &&
749792 protocol == ipvsSvc .Protocol && uint16 (svc .port ) == ipvsSvc .Port {
750793 glog .Infof ("Publishing prometheus metrics " + svc .clusterIP .String () + ":" + strconv .Itoa (svc .port ))
751- serviceActiveConn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
752- servicePpsIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
753- servicePpsOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
794+ serviceBpsIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .BPSIn ))
795+ serviceBpsOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .BPSOut ))
796+ serviceBytesIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .BytesIn ))
797+ serviceBytesOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .BytesOut ))
798+ serviceCPS .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .CPS ))
799+ servicePacketsIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
800+ servicePacketsOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsOut ))
801+ servicePpsIn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PPSIn ))
802+ servicePpsOut .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .PPSOut ))
803+ serviceTotalConn .WithLabelValues (svc .namespace , svc .name , svc .clusterIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
804+
754805 }
755806 if strings .Compare (nsc .nodeIP .String (), ipvsSvc .Address .String ()) == 0 &&
756807 protocol == ipvsSvc .Protocol && uint16 (svc .port ) == ipvsSvc .Port {
757808 glog .Infof ("Publishing prometheus metrics " + nsc .nodeIP .String () + ":" + strconv .Itoa (svc .port ))
758- serviceActiveConn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
759- servicePpsIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
760- servicePpsOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
809+ serviceBpsIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .BPSIn ))
810+ serviceBpsOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .BPSOut ))
811+ serviceBytesIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .BytesIn ))
812+ serviceBytesOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .BytesOut ))
813+ serviceCPS .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .CPS ))
814+ servicePacketsIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsIn ))
815+ servicePacketsOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PacketsOut ))
816+ servicePpsIn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PPSIn ))
817+ servicePpsOut .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .PPSOut ))
818+ serviceTotalConn .WithLabelValues (svc .namespace , svc .name , nsc .nodeIP .String ()).Set (float64 (ipvsSvc .Stats .Connections ))
761819 }
762820 }
763821 }
0 commit comments