@@ -5,66 +5,81 @@ import (
55 "sigs.k8s.io/controller-runtime/pkg/metrics"
66)
77
8+ const (
9+ subnetLabel = "subnet"
10+ subnetCIDRLabel = "subnet_cidr"
11+ )
12+
813var (
9- ipamAllocatedIPCount = prometheus .NewGauge (
14+ ipamAllocatedIPCount = prometheus .NewGaugeVec (
1015 prometheus.GaugeOpts {
1116 Name : "ipam_pod_allocated_ips" ,
1217 Help : "Count of IPs CNS has allocated to Pods." ,
1318 },
19+ []string {subnetLabel , subnetCIDRLabel },
1420 )
15- ipamAvailableIPCount = prometheus .NewGauge (
21+ ipamAvailableIPCount = prometheus .NewGaugeVec (
1622 prometheus.GaugeOpts {
1723 Name : "ipam_available_ips" ,
1824 Help : "Available IP count." ,
1925 },
26+ []string {subnetLabel , subnetCIDRLabel },
2027 )
21- ipamBatchSize = prometheus .NewGauge (
28+ ipamBatchSize = prometheus .NewGaugeVec (
2229 prometheus.GaugeOpts {
2330 Name : "ipam_batch_size" ,
2431 Help : "IPAM IP pool batch size." ,
2532 },
33+ []string {subnetLabel , subnetCIDRLabel },
2634 )
27- ipamCurrentAvailableIPcount = prometheus .NewGauge (
35+ ipamCurrentAvailableIPcount = prometheus .NewGaugeVec (
2836 prometheus.GaugeOpts {
2937 Name : "ipam_current_available_ips" ,
3038 Help : "Current available IP count." ,
3139 },
40+ []string {subnetLabel , subnetCIDRLabel },
3241 )
33- ipamExpectedAvailableIPCount = prometheus .NewGauge (
42+ ipamExpectedAvailableIPCount = prometheus .NewGaugeVec (
3443 prometheus.GaugeOpts {
3544 Name : "ipam_expect_available_ips" ,
3645 Help : "Expected future available IP count assuming the Requested IP count is honored." ,
3746 },
47+ []string {subnetLabel , subnetCIDRLabel },
3848 )
39- ipamMaxIPCount = prometheus .NewGauge (
49+ ipamMaxIPCount = prometheus .NewGaugeVec (
4050 prometheus.GaugeOpts {
4151 Name : "ipam_max_ips" ,
4252 Help : "Maximum IP count." ,
4353 },
54+ []string {subnetLabel , subnetCIDRLabel },
4455 )
45- ipamPendingProgramIPCount = prometheus .NewGauge (
56+ ipamPendingProgramIPCount = prometheus .NewGaugeVec (
4657 prometheus.GaugeOpts {
4758 Name : "ipam_pending_programming_ips" ,
4859 Help : "Pending programming IP count." ,
4960 },
61+ []string {subnetLabel , subnetCIDRLabel },
5062 )
51- ipamPendingReleaseIPCount = prometheus .NewGauge (
63+ ipamPendingReleaseIPCount = prometheus .NewGaugeVec (
5264 prometheus.GaugeOpts {
5365 Name : "ipam_pending_release_ips" ,
5466 Help : "Pending release IP count." ,
5567 },
68+ []string {subnetLabel , subnetCIDRLabel },
5669 )
57- ipamRequestedIPConfigCount = prometheus .NewGauge (
70+ ipamRequestedIPConfigCount = prometheus .NewGaugeVec (
5871 prometheus.GaugeOpts {
5972 Name : "ipam_requested_ips" ,
6073 Help : "Requested IP count." ,
6174 },
75+ []string {subnetLabel , subnetCIDRLabel },
6276 )
63- ipamTotalIPCount = prometheus .NewGauge (
77+ ipamTotalIPCount = prometheus .NewGaugeVec (
6478 prometheus.GaugeOpts {
6579 Name : "ipam_total_ips" ,
6680 Help : "Count of total IP pool size allocated to CNS by DNC." ,
6781 },
82+ []string {subnetLabel , subnetCIDRLabel },
6883 )
6984)
7085
@@ -83,15 +98,15 @@ func init() {
8398 )
8499}
85100
86- func observeIPPoolState (state ipPoolState , meta metaState ) {
87- ipamAllocatedIPCount .Set (float64 (state .allocatedToPods ))
88- ipamAvailableIPCount .Set (float64 (state .available ))
89- ipamBatchSize .Set (float64 (meta .batch ))
90- ipamCurrentAvailableIPcount .Set (float64 (state .currentAvailableIPs ))
91- ipamExpectedAvailableIPCount .Set (float64 (state .expectedAvailableIPs ))
92- ipamMaxIPCount .Set (float64 (meta .max ))
93- ipamPendingProgramIPCount .Set (float64 (state .pendingProgramming ))
94- ipamPendingReleaseIPCount .Set (float64 (state .pendingRelease ))
95- ipamRequestedIPConfigCount .Set (float64 (state .requestedIPs ))
96- ipamTotalIPCount .Set (float64 (state .totalIPs ))
101+ func observeIPPoolState (state ipPoolState , meta metaState , labels [] string ) {
102+ ipamAllocatedIPCount .WithLabelValues ( labels ... ). Set (float64 (state .allocatedToPods ))
103+ ipamAvailableIPCount .WithLabelValues ( labels ... ). Set (float64 (state .available ))
104+ ipamBatchSize .WithLabelValues ( labels ... ). Set (float64 (meta .batch ))
105+ ipamCurrentAvailableIPcount .WithLabelValues ( labels ... ). Set (float64 (state .currentAvailableIPs ))
106+ ipamExpectedAvailableIPCount .WithLabelValues ( labels ... ). Set (float64 (state .expectedAvailableIPs ))
107+ ipamMaxIPCount .WithLabelValues ( labels ... ). Set (float64 (meta .max ))
108+ ipamPendingProgramIPCount .WithLabelValues ( labels ... ). Set (float64 (state .pendingProgramming ))
109+ ipamPendingReleaseIPCount .WithLabelValues ( labels ... ). Set (float64 (state .pendingRelease ))
110+ ipamRequestedIPConfigCount .WithLabelValues ( labels ... ). Set (float64 (state .requestedIPs ))
111+ ipamTotalIPCount .WithLabelValues ( labels ... ). Set (float64 (state .totalIPs ))
97112}
0 commit comments