...

Source file src/k8s.io/kubernetes/pkg/registry/core/service/ipallocator/controller/metrics.go

Documentation: k8s.io/kubernetes/pkg/registry/core/service/ipallocator/controller

     1  /*
     2  Copyright 2023 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 controller
    18  
    19  import (
    20  	"sync"
    21  
    22  	"k8s.io/component-base/metrics"
    23  	"k8s.io/component-base/metrics/legacyregistry"
    24  )
    25  
    26  const (
    27  	namespace = "apiserver"
    28  	subsystem = "clusterip_repair"
    29  )
    30  
    31  var (
    32  	// clusterIPRepairIPErrors indicates the number of errors found by the repair loop
    33  	// divided by the type of error:
    34  	// leak, repair, full, outOfRange, duplicate, invalid, unknown
    35  	clusterIPRepairIPErrors = metrics.NewCounterVec(
    36  		&metrics.CounterOpts{
    37  			Namespace:      namespace,
    38  			Subsystem:      subsystem,
    39  			Name:           "ip_errors_total",
    40  			Help:           "Number of errors detected on clusterips by the repair loop broken down by type of error: leak, repair, full, outOfRange, duplicate, unknown, invalid",
    41  			StabilityLevel: metrics.ALPHA,
    42  		},
    43  		[]string{"type"},
    44  	)
    45  	// clusterIPRepairReconcileErrors indicates the number of times the repair loop has failed to repair
    46  	// the errors it detected.
    47  	clusterIPRepairReconcileErrors = metrics.NewCounter(
    48  		&metrics.CounterOpts{
    49  			Namespace:      namespace,
    50  			Subsystem:      subsystem,
    51  			Name:           "reconcile_errors_total",
    52  			Help:           "Number of reconciliation failures on the clusterip repair reconcile loop",
    53  			StabilityLevel: metrics.ALPHA,
    54  		},
    55  	)
    56  )
    57  
    58  var registerMetricsOnce sync.Once
    59  
    60  func registerMetrics() {
    61  	registerMetricsOnce.Do(func() {
    62  		legacyregistry.MustRegister(clusterIPRepairIPErrors)
    63  		legacyregistry.MustRegister(clusterIPRepairReconcileErrors)
    64  	})
    65  }
    66  

View as plain text