1- package ipampool
1+ package metrics
22
33import (
44 "github.com/prometheus/client_golang/prometheus"
55 "sigs.k8s.io/controller-runtime/pkg/metrics"
66)
77
88const (
9- subnetLabel = "subnet"
10- subnetCIDRLabel = "subnet_cidr"
11- podnetARMIDLabel = "podnet_arm_id"
9+ SubnetLabel = "subnet"
10+ SubnetCIDRLabel = "subnet_cidr"
11+ PodnetARMIDLabel = "podnet_arm_id"
1212 customerMetricLabel = "customer_metric"
1313 customerMetricLabelValue = "customer metric"
14- subnetExhaustionStateLabel = "subnet_exhaustion_state"
14+ SubnetExhaustionStateLabel = "subnet_exhaustion_state"
1515 SubnetIPExhausted = 1
1616 SubnetIPNotExhausted = 0
1717)
@@ -23,110 +23,110 @@ var (
2323 Help : "IPs currently in use by Pods on this CNS Node." ,
2424 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
2525 },
26- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
26+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
2727 )
2828 IpamAvailableIPCount = prometheus .NewGaugeVec (
2929 prometheus.GaugeOpts {
3030 Name : "cx_ipam_available_ips" ,
3131 Help : "IPs available on this CNS Node for use by a Pod." ,
3232 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
3333 },
34- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
34+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
3535 )
3636 IpamBatchSize = prometheus .NewGaugeVec (
3737 prometheus.GaugeOpts {
3838 Name : "cx_ipam_batch_size" ,
3939 Help : "IPAM IP pool scaling batch size." ,
4040 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
4141 },
42- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
42+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
4343 )
4444 IpamCurrentAvailableIPcount = prometheus .NewGaugeVec (
4545 prometheus.GaugeOpts {
4646 Name : "cx_ipam_current_available_ips" ,
4747 Help : "Current available IP count." ,
4848 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
4949 },
50- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
50+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
5151 )
5252 IpamExpectedAvailableIPCount = prometheus .NewGaugeVec (
5353 prometheus.GaugeOpts {
5454 Name : "cx_ipam_expect_available_ips" ,
5555 Help : "Expected future available IP count assuming the Requested IP count is honored." ,
5656 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
5757 },
58- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
58+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
5959 )
6060 IpamMaxIPCount = prometheus .NewGaugeVec (
6161 prometheus.GaugeOpts {
6262 Name : "cx_ipam_max_ips" ,
6363 Help : "Maximum Secondary IPs allowed on this Node." ,
6464 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
6565 },
66- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
66+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
6767 )
6868 IpamPendingProgramIPCount = prometheus .NewGaugeVec (
6969 prometheus.GaugeOpts {
7070 Name : "cx_ipam_pending_programming_ips" ,
7171 Help : "IPs reserved but not yet available (Pending Programming)." ,
7272 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
7373 },
74- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
74+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
7575 )
7676 IpamPendingReleaseIPCount = prometheus .NewGaugeVec (
7777 prometheus.GaugeOpts {
7878 Name : "cx_ipam_pending_release_ips" ,
7979 Help : "IPs reserved but not available anymore (Pending Release)." ,
8080 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
8181 },
82- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
82+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
8383 )
8484 IpamPrimaryIPCount = prometheus .NewGaugeVec (
8585 prometheus.GaugeOpts {
8686 Name : "cx_ipam_primary_ips" ,
8787 Help : "NC Primary IP count (reserved from Pod Subnet for DNS and IMDS SNAT)." ,
8888 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
8989 },
90- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
90+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
9191 )
9292 IpamRequestedIPConfigCount = prometheus .NewGaugeVec (
9393 prometheus.GaugeOpts {
9494 Name : "cx_ipam_requested_ips" ,
9595 Help : "Secondary Pod Subnet IPs requested by this CNS Node (for Pods)." ,
9696 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
9797 },
98- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
98+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
9999 )
100100 IpamSecondaryIPCount = prometheus .NewGaugeVec (
101101 prometheus.GaugeOpts {
102102 Name : "cx_ipam_secondary_ips" ,
103103 Help : "Node NC Secondary IP count (reserved usable by Pods)." ,
104104 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
105105 },
106- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
106+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
107107 )
108108 IpamTotalIPCount = prometheus .NewGaugeVec (
109109 prometheus.GaugeOpts {
110110 Name : "cx_ipam_total_ips" ,
111111 Help : "Count of total IP pool size allocated to CNS by DNC." ,
112112 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
113113 },
114- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
114+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
115115 )
116116 IpamSubnetExhaustionState = prometheus .NewGaugeVec (
117117 prometheus.GaugeOpts {
118118 Name : "cx_ipam_subnet_exhaustion_state" ,
119119 Help : "IPAM view of subnet exhaustion state" ,
120120 ConstLabels : prometheus.Labels {customerMetricLabel : customerMetricLabelValue },
121121 },
122- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel },
122+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel },
123123 )
124124 IpamSubnetExhaustionCount = prometheus .NewCounterVec (
125125 prometheus.CounterOpts {
126126 Name : "cx_ipam_subnet_exhaustion_state_count_total" ,
127127 Help : "Count of the number of times the ipam pool monitor sees subnet exhaustion" ,
128128 },
129- []string {subnetLabel , subnetCIDRLabel , podnetARMIDLabel , subnetExhaustionStateLabel },
129+ []string {SubnetLabel , SubnetCIDRLabel , PodnetARMIDLabel , SubnetExhaustionStateLabel },
130130 )
131131)
132132
@@ -148,24 +148,3 @@ func init() {
148148 IpamSubnetExhaustionCount ,
149149 )
150150}
151-
152- func observeIPPoolState (state ipPoolState , meta metaState ) {
153- labels := []string {meta .subnet , meta .subnetCIDR , meta .subnetARMID }
154- IpamAllocatedIPCount .WithLabelValues (labels ... ).Set (float64 (state .allocatedToPods ))
155- IpamAvailableIPCount .WithLabelValues (labels ... ).Set (float64 (state .available ))
156- IpamBatchSize .WithLabelValues (labels ... ).Set (float64 (meta .batch ))
157- IpamCurrentAvailableIPcount .WithLabelValues (labels ... ).Set (float64 (state .currentAvailableIPs ))
158- IpamExpectedAvailableIPCount .WithLabelValues (labels ... ).Set (float64 (state .expectedAvailableIPs ))
159- IpamMaxIPCount .WithLabelValues (labels ... ).Set (float64 (meta .max ))
160- IpamPendingProgramIPCount .WithLabelValues (labels ... ).Set (float64 (state .pendingProgramming ))
161- IpamPendingReleaseIPCount .WithLabelValues (labels ... ).Set (float64 (state .pendingRelease ))
162- IpamPrimaryIPCount .WithLabelValues (labels ... ).Set (float64 (len (meta .primaryIPAddresses )))
163- IpamRequestedIPConfigCount .WithLabelValues (labels ... ).Set (float64 (state .requestedIPs ))
164- IpamSecondaryIPCount .WithLabelValues (labels ... ).Set (float64 (state .secondaryIPs ))
165- IpamTotalIPCount .WithLabelValues (labels ... ).Set (float64 (state .secondaryIPs + int64 (len (meta .primaryIPAddresses ))))
166- if meta .exhausted {
167- IpamSubnetExhaustionState .WithLabelValues (labels ... ).Set (float64 (SubnetIPExhausted ))
168- } else {
169- IpamSubnetExhaustionState .WithLabelValues (labels ... ).Set (float64 (SubnetIPNotExhausted ))
170- }
171- }
0 commit comments