123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package metrics
- import (
- "sync"
- "time"
- "github.com/prometheus/client_golang/prometheus"
- )
- const kubeProxySubsystem = "kubeproxy"
- var (
-
- SyncProxyRulesLatency = prometheus.NewHistogram(
- prometheus.HistogramOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_duration_seconds",
- Help: "SyncProxyRules latency in seconds",
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
- },
- )
-
- DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram(
- prometheus.HistogramOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_latency_microseconds",
- Help: "(Deprecated) SyncProxyRules latency in microseconds",
- Buckets: prometheus.ExponentialBuckets(1000, 2, 15),
- },
- )
-
-
- SyncProxyRulesLastTimestamp = prometheus.NewGauge(
- prometheus.GaugeOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_last_timestamp_seconds",
- Help: "The last time proxy rules were successfully synced",
- },
- )
-
-
-
-
-
-
-
- NetworkProgrammingLatency = prometheus.NewHistogram(
- prometheus.HistogramOpts{
- Subsystem: kubeProxySubsystem,
- Name: "network_programming_duration_seconds",
- Help: "In Cluster Network Programming Latency in seconds",
-
-
- Buckets: prometheus.ExponentialBuckets(0.001, 2, 20),
- },
- )
-
-
- EndpointChangesPending = prometheus.NewGauge(
- prometheus.GaugeOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_endpoint_changes_pending",
- Help: "Pending proxy rules Endpoint changes",
- },
- )
-
-
- EndpointChangesTotal = prometheus.NewCounter(
- prometheus.CounterOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_endpoint_changes_total",
- Help: "Cumulative proxy rules Endpoint changes",
- },
- )
-
-
- ServiceChangesPending = prometheus.NewGauge(
- prometheus.GaugeOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_service_changes_pending",
- Help: "Pending proxy rules Service changes",
- },
- )
-
-
- ServiceChangesTotal = prometheus.NewCounter(
- prometheus.CounterOpts{
- Subsystem: kubeProxySubsystem,
- Name: "sync_proxy_rules_service_changes_total",
- Help: "Cumulative proxy rules Service changes",
- },
- )
- )
- var registerMetricsOnce sync.Once
- func RegisterMetrics() {
- registerMetricsOnce.Do(func() {
- prometheus.MustRegister(SyncProxyRulesLatency)
- prometheus.MustRegister(DeprecatedSyncProxyRulesLatency)
- prometheus.MustRegister(SyncProxyRulesLastTimestamp)
- prometheus.MustRegister(NetworkProgrammingLatency)
- prometheus.MustRegister(EndpointChangesPending)
- prometheus.MustRegister(EndpointChangesTotal)
- prometheus.MustRegister(ServiceChangesPending)
- prometheus.MustRegister(ServiceChangesTotal)
- })
- }
- func SinceInMicroseconds(start time.Time) float64 {
- return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
- }
- func SinceInSeconds(start time.Time) float64 {
- return time.Since(start).Seconds()
- }
|