mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #81626 from logicalhan/proxy-migration
migrate kube-proxy metrics to stability framework
This commit is contained in:
		@@ -20,10 +20,9 @@ go_library(
 | 
				
			|||||||
    importpath = "k8s.io/kubernetes/cmd/kube-proxy",
 | 
					    importpath = "k8s.io/kubernetes/cmd/kube-proxy",
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//cmd/kube-proxy/app:go_default_library",
 | 
					        "//cmd/kube-proxy/app:go_default_library",
 | 
				
			||||||
        "//pkg/client/metrics/prometheus:go_default_library",
 | 
					 | 
				
			||||||
        "//pkg/version/prometheus:go_default_library",
 | 
					 | 
				
			||||||
        "//staging/src/k8s.io/component-base/cli/flag:go_default_library",
 | 
					        "//staging/src/k8s.io/component-base/cli/flag:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/component-base/logs:go_default_library",
 | 
					        "//staging/src/k8s.io/component-base/logs:go_default_library",
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics/prometheus/restclient:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/spf13/pflag:go_default_library",
 | 
					        "//vendor/github.com/spf13/pflag:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,9 +63,9 @@ go_library(
 | 
				
			|||||||
        "//staging/src/k8s.io/client-go/tools/record:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/tools/record:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/component-base/cli/flag:go_default_library",
 | 
					        "//staging/src/k8s.io/component-base/cli/flag:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/component-base/config:go_default_library",
 | 
					        "//staging/src/k8s.io/component-base/config:go_default_library",
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/kube-proxy/config/v1alpha1:go_default_library",
 | 
					        "//staging/src/k8s.io/kube-proxy/config/v1alpha1:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/fsnotify/fsnotify:go_default_library",
 | 
					        "//vendor/github.com/fsnotify/fsnotify:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
					 | 
				
			||||||
        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
					        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/spf13/pflag:go_default_library",
 | 
					        "//vendor/github.com/spf13/pflag:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/klog:go_default_library",
 | 
					        "//vendor/k8s.io/klog:go_default_library",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,10 @@ import (
 | 
				
			|||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/fsnotify/fsnotify"
 | 
				
			||||||
 | 
						"github.com/spf13/cobra"
 | 
				
			||||||
 | 
						"github.com/spf13/pflag"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
	v1meta "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						v1meta "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/labels"
 | 
						"k8s.io/apimachinery/pkg/labels"
 | 
				
			||||||
@@ -48,6 +52,8 @@ import (
 | 
				
			|||||||
	"k8s.io/client-go/tools/record"
 | 
						"k8s.io/client-go/tools/record"
 | 
				
			||||||
	cliflag "k8s.io/component-base/cli/flag"
 | 
						cliflag "k8s.io/component-base/cli/flag"
 | 
				
			||||||
	componentbaseconfig "k8s.io/component-base/config"
 | 
						componentbaseconfig "k8s.io/component-base/config"
 | 
				
			||||||
 | 
						"k8s.io/component-base/metrics/legacyregistry"
 | 
				
			||||||
 | 
						"k8s.io/klog"
 | 
				
			||||||
	"k8s.io/kube-proxy/config/v1alpha1"
 | 
						"k8s.io/kube-proxy/config/v1alpha1"
 | 
				
			||||||
	api "k8s.io/kubernetes/pkg/apis/core"
 | 
						api "k8s.io/kubernetes/pkg/apis/core"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
						"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
				
			||||||
@@ -74,12 +80,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/version/verflag"
 | 
						"k8s.io/kubernetes/pkg/version/verflag"
 | 
				
			||||||
	"k8s.io/utils/exec"
 | 
						"k8s.io/utils/exec"
 | 
				
			||||||
	utilpointer "k8s.io/utils/pointer"
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/fsnotify/fsnotify"
 | 
					 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
					 | 
				
			||||||
	"github.com/spf13/cobra"
 | 
					 | 
				
			||||||
	"github.com/spf13/pflag"
 | 
					 | 
				
			||||||
	"k8s.io/klog"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -551,7 +551,7 @@ func (s *ProxyServer) Run() error {
 | 
				
			|||||||
		proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
 | 
							proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
			fmt.Fprintf(w, "%s", s.ProxyMode)
 | 
								fmt.Fprintf(w, "%s", s.ProxyMode)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		proxyMux.Handle("/metrics", prometheus.Handler())
 | 
							proxyMux.Handle("/metrics", legacyregistry.Handler())
 | 
				
			||||||
		if s.EnableProfiling {
 | 
							if s.EnableProfiling {
 | 
				
			||||||
			routes.Profiling{}.Install(proxyMux)
 | 
								routes.Profiling{}.Install(proxyMux)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,9 +26,8 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cliflag "k8s.io/component-base/cli/flag"
 | 
						cliflag "k8s.io/component-base/cli/flag"
 | 
				
			||||||
	"k8s.io/component-base/logs"
 | 
						"k8s.io/component-base/logs"
 | 
				
			||||||
 | 
						_ "k8s.io/component-base/metrics/prometheus/restclient" // for client metric registration
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/kube-proxy/app"
 | 
						"k8s.io/kubernetes/cmd/kube-proxy/app"
 | 
				
			||||||
	_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
 | 
					 | 
				
			||||||
	_ "k8s.io/kubernetes/pkg/version/prometheus"        // for version metric registration
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,11 @@ go_library(
 | 
				
			|||||||
    srcs = ["metrics.go"],
 | 
					    srcs = ["metrics.go"],
 | 
				
			||||||
    importpath = "k8s.io/kubernetes/pkg/proxy/metrics",
 | 
					    importpath = "k8s.io/kubernetes/pkg/proxy/metrics",
 | 
				
			||||||
    visibility = ["//visibility:public"],
 | 
					    visibility = ["//visibility:public"],
 | 
				
			||||||
    deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"],
 | 
					    deps = [
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics:go_default_library",
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
filegroup(
 | 
					filegroup(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,38 +21,44 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
						"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/component-base/metrics"
 | 
				
			||||||
 | 
						"k8s.io/component-base/metrics/legacyregistry"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const kubeProxySubsystem = "kubeproxy"
 | 
					const kubeProxySubsystem = "kubeproxy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	// SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
 | 
						// SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
 | 
				
			||||||
	SyncProxyRulesLatency = prometheus.NewHistogram(
 | 
						SyncProxyRulesLatency = metrics.NewHistogram(
 | 
				
			||||||
		prometheus.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_duration_seconds",
 | 
								Name:           "sync_proxy_rules_duration_seconds",
 | 
				
			||||||
			Help:           "SyncProxyRules latency in seconds",
 | 
								Help:           "SyncProxyRules latency in seconds",
 | 
				
			||||||
			Buckets:        prometheus.ExponentialBuckets(0.001, 2, 15),
 | 
								Buckets:        prometheus.ExponentialBuckets(0.001, 2, 15),
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// DeprecatedSyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
 | 
						// DeprecatedSyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
 | 
				
			||||||
	DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram(
 | 
						DeprecatedSyncProxyRulesLatency = metrics.NewHistogram(
 | 
				
			||||||
		prometheus.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_latency_microseconds",
 | 
								Name:           "sync_proxy_rules_latency_microseconds",
 | 
				
			||||||
			Help:           "(Deprecated) SyncProxyRules latency in microseconds",
 | 
								Help:           "(Deprecated) SyncProxyRules latency in microseconds",
 | 
				
			||||||
			Buckets:        prometheus.ExponentialBuckets(1000, 2, 15),
 | 
								Buckets:        prometheus.ExponentialBuckets(1000, 2, 15),
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
 | 
						// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
 | 
				
			||||||
	// successfully synced.
 | 
						// successfully synced.
 | 
				
			||||||
	SyncProxyRulesLastTimestamp = prometheus.NewGauge(
 | 
						SyncProxyRulesLastTimestamp = metrics.NewGauge(
 | 
				
			||||||
		prometheus.GaugeOpts{
 | 
							&metrics.GaugeOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_last_timestamp_seconds",
 | 
								Name:           "sync_proxy_rules_last_timestamp_seconds",
 | 
				
			||||||
			Help:           "The last time proxy rules were successfully synced",
 | 
								Help:           "The last time proxy rules were successfully synced",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -63,8 +69,8 @@ var (
 | 
				
			|||||||
	// Note that the metrics is partially based on the time exported by the endpoints controller on
 | 
						// Note that the metrics is partially based on the time exported by the endpoints controller on
 | 
				
			||||||
	// the master machine. The measurement may be inaccurate if there is a clock drift between the
 | 
						// the master machine. The measurement may be inaccurate if there is a clock drift between the
 | 
				
			||||||
	// node and master machine.
 | 
						// node and master machine.
 | 
				
			||||||
	NetworkProgrammingLatency = prometheus.NewHistogram(
 | 
						NetworkProgrammingLatency = metrics.NewHistogram(
 | 
				
			||||||
		prometheus.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem: kubeProxySubsystem,
 | 
								Subsystem: kubeProxySubsystem,
 | 
				
			||||||
			Name:      "network_programming_duration_seconds",
 | 
								Name:      "network_programming_duration_seconds",
 | 
				
			||||||
			Help:      "In Cluster Network Programming Latency in seconds",
 | 
								Help:      "In Cluster Network Programming Latency in seconds",
 | 
				
			||||||
@@ -74,56 +80,62 @@ var (
 | 
				
			|||||||
				prometheus.LinearBuckets(60, 5, 12),     // 60s, 65s, 70s, ... 115s
 | 
									prometheus.LinearBuckets(60, 5, 12),     // 60s, 65s, 70s, ... 115s
 | 
				
			||||||
				prometheus.LinearBuckets(120, 30, 7),    // 2min, 2.5min, 3min, ..., 5min
 | 
									prometheus.LinearBuckets(120, 30, 7),    // 2min, 2.5min, 3min, ..., 5min
 | 
				
			||||||
			),
 | 
								),
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// EndpointChangesPending is the number of pending endpoint changes that
 | 
						// EndpointChangesPending is the number of pending endpoint changes that
 | 
				
			||||||
	// have not yet been synced to the proxy.
 | 
						// have not yet been synced to the proxy.
 | 
				
			||||||
	EndpointChangesPending = prometheus.NewGauge(
 | 
						EndpointChangesPending = metrics.NewGauge(
 | 
				
			||||||
		prometheus.GaugeOpts{
 | 
							&metrics.GaugeOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_endpoint_changes_pending",
 | 
								Name:           "sync_proxy_rules_endpoint_changes_pending",
 | 
				
			||||||
			Help:           "Pending proxy rules Endpoint changes",
 | 
								Help:           "Pending proxy rules Endpoint changes",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// EndpointChangesTotal is the number of endpoint changes that the proxy
 | 
						// EndpointChangesTotal is the number of endpoint changes that the proxy
 | 
				
			||||||
	// has seen.
 | 
						// has seen.
 | 
				
			||||||
	EndpointChangesTotal = prometheus.NewCounter(
 | 
						EndpointChangesTotal = metrics.NewCounter(
 | 
				
			||||||
		prometheus.CounterOpts{
 | 
							&metrics.CounterOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_endpoint_changes_total",
 | 
								Name:           "sync_proxy_rules_endpoint_changes_total",
 | 
				
			||||||
			Help:           "Cumulative proxy rules Endpoint changes",
 | 
								Help:           "Cumulative proxy rules Endpoint changes",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ServiceChangesPending is the number of pending service changes that
 | 
						// ServiceChangesPending is the number of pending service changes that
 | 
				
			||||||
	// have not yet been synced to the proxy.
 | 
						// have not yet been synced to the proxy.
 | 
				
			||||||
	ServiceChangesPending = prometheus.NewGauge(
 | 
						ServiceChangesPending = metrics.NewGauge(
 | 
				
			||||||
		prometheus.GaugeOpts{
 | 
							&metrics.GaugeOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_service_changes_pending",
 | 
								Name:           "sync_proxy_rules_service_changes_pending",
 | 
				
			||||||
			Help:           "Pending proxy rules Service changes",
 | 
								Help:           "Pending proxy rules Service changes",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ServiceChangesTotal is the number of service changes that the proxy has
 | 
						// ServiceChangesTotal is the number of service changes that the proxy has
 | 
				
			||||||
	// seen.
 | 
						// seen.
 | 
				
			||||||
	ServiceChangesTotal = prometheus.NewCounter(
 | 
						ServiceChangesTotal = metrics.NewCounter(
 | 
				
			||||||
		prometheus.CounterOpts{
 | 
							&metrics.CounterOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_service_changes_total",
 | 
								Name:           "sync_proxy_rules_service_changes_total",
 | 
				
			||||||
			Help:           "Cumulative proxy rules Service changes",
 | 
								Help:           "Cumulative proxy rules Service changes",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// IptablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has
 | 
						// IptablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has
 | 
				
			||||||
	// seen.
 | 
						// seen.
 | 
				
			||||||
	IptablesRestoreFailuresTotal = prometheus.NewCounter(
 | 
						IptablesRestoreFailuresTotal = metrics.NewCounter(
 | 
				
			||||||
		prometheus.CounterOpts{
 | 
							&metrics.CounterOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_iptables_restore_failures_total",
 | 
								Name:           "sync_proxy_rules_iptables_restore_failures_total",
 | 
				
			||||||
			Help:           "Cumulative proxy iptables restore failures",
 | 
								Help:           "Cumulative proxy iptables restore failures",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -133,15 +145,15 @@ var registerMetricsOnce sync.Once
 | 
				
			|||||||
// RegisterMetrics registers kube-proxy metrics.
 | 
					// RegisterMetrics registers kube-proxy metrics.
 | 
				
			||||||
func RegisterMetrics() {
 | 
					func RegisterMetrics() {
 | 
				
			||||||
	registerMetricsOnce.Do(func() {
 | 
						registerMetricsOnce.Do(func() {
 | 
				
			||||||
		prometheus.MustRegister(SyncProxyRulesLatency)
 | 
							legacyregistry.MustRegister(SyncProxyRulesLatency)
 | 
				
			||||||
		prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
 | 
							legacyregistry.MustRegister(DeprecatedSyncProxyRulesLatency)
 | 
				
			||||||
		prometheus.MustRegister(SyncProxyRulesLastTimestamp)
 | 
							legacyregistry.MustRegister(SyncProxyRulesLastTimestamp)
 | 
				
			||||||
		prometheus.MustRegister(NetworkProgrammingLatency)
 | 
							legacyregistry.MustRegister(NetworkProgrammingLatency)
 | 
				
			||||||
		prometheus.MustRegister(EndpointChangesPending)
 | 
							legacyregistry.MustRegister(EndpointChangesPending)
 | 
				
			||||||
		prometheus.MustRegister(EndpointChangesTotal)
 | 
							legacyregistry.MustRegister(EndpointChangesTotal)
 | 
				
			||||||
		prometheus.MustRegister(ServiceChangesPending)
 | 
							legacyregistry.MustRegister(ServiceChangesPending)
 | 
				
			||||||
		prometheus.MustRegister(ServiceChangesTotal)
 | 
							legacyregistry.MustRegister(ServiceChangesTotal)
 | 
				
			||||||
		prometheus.MustRegister(IptablesRestoreFailuresTotal)
 | 
							legacyregistry.MustRegister(IptablesRestoreFailuresTotal)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,8 @@ go_library(
 | 
				
			|||||||
    importpath = "k8s.io/kubernetes/pkg/proxy/winkernel",
 | 
					    importpath = "k8s.io/kubernetes/pkg/proxy/winkernel",
 | 
				
			||||||
    visibility = ["//visibility:public"],
 | 
					    visibility = ["//visibility:public"],
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics:go_default_library",
 | 
				
			||||||
 | 
					        "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
					        "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
 | 
				
			||||||
    ] + select({
 | 
					    ] + select({
 | 
				
			||||||
        "@io_bazel_rules_go//go/platform:windows": [
 | 
					        "@io_bazel_rules_go//go/platform:windows": [
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,36 +21,42 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
						"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/component-base/metrics"
 | 
				
			||||||
 | 
						"k8s.io/component-base/metrics/legacyregistry"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const kubeProxySubsystem = "kubeproxy"
 | 
					const kubeProxySubsystem = "kubeproxy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	SyncProxyRulesLatency = prometheus.NewHistogram(
 | 
						SyncProxyRulesLatency = metrics.NewHistogram(
 | 
				
			||||||
		prometheus.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_duration_seconds",
 | 
								Name:           "sync_proxy_rules_duration_seconds",
 | 
				
			||||||
			Help:           "SyncProxyRules latency in seconds",
 | 
								Help:           "SyncProxyRules latency in seconds",
 | 
				
			||||||
			Buckets:        prometheus.ExponentialBuckets(0.001, 2, 15),
 | 
								Buckets:        prometheus.ExponentialBuckets(0.001, 2, 15),
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram(
 | 
						DeprecatedSyncProxyRulesLatency = metrics.NewHistogram(
 | 
				
			||||||
		prometheus.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_latency_microseconds",
 | 
								Name:           "sync_proxy_rules_latency_microseconds",
 | 
				
			||||||
			Help:           "(Deprecated) SyncProxyRules latency in microseconds",
 | 
								Help:           "(Deprecated) SyncProxyRules latency in microseconds",
 | 
				
			||||||
			Buckets:        prometheus.ExponentialBuckets(1000, 2, 15),
 | 
								Buckets:        prometheus.ExponentialBuckets(1000, 2, 15),
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
 | 
						// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
 | 
				
			||||||
	// successfully synced.
 | 
						// successfully synced.
 | 
				
			||||||
	SyncProxyRulesLastTimestamp = prometheus.NewGauge(
 | 
						SyncProxyRulesLastTimestamp = metrics.NewGauge(
 | 
				
			||||||
		prometheus.GaugeOpts{
 | 
							&metrics.GaugeOpts{
 | 
				
			||||||
			Subsystem:      kubeProxySubsystem,
 | 
								Subsystem:      kubeProxySubsystem,
 | 
				
			||||||
			Name:           "sync_proxy_rules_last_timestamp_seconds",
 | 
								Name:           "sync_proxy_rules_last_timestamp_seconds",
 | 
				
			||||||
			Help:           "The last time proxy rules were successfully synced",
 | 
								Help:           "The last time proxy rules were successfully synced",
 | 
				
			||||||
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -59,9 +65,9 @@ var registerMetricsOnce sync.Once
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func RegisterMetrics() {
 | 
					func RegisterMetrics() {
 | 
				
			||||||
	registerMetricsOnce.Do(func() {
 | 
						registerMetricsOnce.Do(func() {
 | 
				
			||||||
		prometheus.MustRegister(SyncProxyRulesLatency)
 | 
							legacyregistry.MustRegister(SyncProxyRulesLatency)
 | 
				
			||||||
		prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
 | 
							legacyregistry.MustRegister(DeprecatedSyncProxyRulesLatency)
 | 
				
			||||||
		prometheus.MustRegister(SyncProxyRulesLastTimestamp)
 | 
							legacyregistry.MustRegister(SyncProxyRulesLastTimestamp)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,6 +63,7 @@ type GaugeMetric interface {
 | 
				
			|||||||
	Dec()
 | 
						Dec()
 | 
				
			||||||
	Add(float64)
 | 
						Add(float64)
 | 
				
			||||||
	Write(out *dto.Metric) error
 | 
						Write(out *dto.Metric) error
 | 
				
			||||||
 | 
						SetToCurrentTime()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ObserverMetric captures individual observations.
 | 
					// ObserverMetric captures individual observations.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user