...

Source file src/k8s.io/kubernetes/pkg/controller/nodeipam/ipam/cidrset/metrics.go

Documentation: k8s.io/kubernetes/pkg/controller/nodeipam/ipam/cidrset

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package cidrset
    18  
    19  import (
    20  	"sync"
    21  
    22  	"k8s.io/component-base/metrics"
    23  	"k8s.io/component-base/metrics/legacyregistry"
    24  )
    25  
    26  const nodeIpamSubsystem = "node_ipam_controller"
    27  
    28  var (
    29  	cidrSetAllocations = metrics.NewCounterVec(
    30  		&metrics.CounterOpts{
    31  			Subsystem:      nodeIpamSubsystem,
    32  			Name:           "cidrset_cidrs_allocations_total",
    33  			Help:           "Counter measuring total number of CIDR allocations.",
    34  			StabilityLevel: metrics.ALPHA,
    35  		},
    36  		[]string{"clusterCIDR"},
    37  	)
    38  	cidrSetReleases = metrics.NewCounterVec(
    39  		&metrics.CounterOpts{
    40  			Subsystem:      nodeIpamSubsystem,
    41  			Name:           "cidrset_cidrs_releases_total",
    42  			Help:           "Counter measuring total number of CIDR releases.",
    43  			StabilityLevel: metrics.ALPHA,
    44  		},
    45  		[]string{"clusterCIDR"},
    46  	)
    47  	// This is a gauge, as in theory, a limit can increase or decrease.
    48  	cidrSetMaxCidrs = metrics.NewGaugeVec(
    49  		&metrics.GaugeOpts{
    50  			Subsystem:      nodeIpamSubsystem,
    51  			Name:           "cirdset_max_cidrs",
    52  			Help:           "Maximum number of CIDRs that can be allocated.",
    53  			StabilityLevel: metrics.ALPHA,
    54  		},
    55  		[]string{"clusterCIDR"},
    56  	)
    57  	cidrSetUsage = metrics.NewGaugeVec(
    58  		&metrics.GaugeOpts{
    59  			Subsystem:      nodeIpamSubsystem,
    60  			Name:           "cidrset_usage_cidrs",
    61  			Help:           "Gauge measuring percentage of allocated CIDRs.",
    62  			StabilityLevel: metrics.ALPHA,
    63  		},
    64  		[]string{"clusterCIDR"},
    65  	)
    66  	cidrSetAllocationTriesPerRequest = metrics.NewHistogramVec(
    67  		&metrics.HistogramOpts{
    68  			Subsystem:      nodeIpamSubsystem,
    69  			Name:           "cidrset_allocation_tries_per_request",
    70  			Help:           "Number of endpoints added on each Service sync",
    71  			StabilityLevel: metrics.ALPHA,
    72  			Buckets:        metrics.ExponentialBuckets(1, 5, 5),
    73  		},
    74  		[]string{"clusterCIDR"},
    75  	)
    76  )
    77  
    78  var registerMetrics sync.Once
    79  
    80  // registerCidrsetMetrics the metrics that are to be monitored.
    81  func registerCidrsetMetrics() {
    82  	registerMetrics.Do(func() {
    83  		legacyregistry.MustRegister(cidrSetAllocations)
    84  		legacyregistry.MustRegister(cidrSetReleases)
    85  		legacyregistry.MustRegister(cidrSetMaxCidrs)
    86  		legacyregistry.MustRegister(cidrSetUsage)
    87  		legacyregistry.MustRegister(cidrSetAllocationTriesPerRequest)
    88  	})
    89  }
    90  

View as plain text