Skip to content

Commit a9f47c3

Browse files
authored
Merge pull request kubernetes#90175 from squeed/proxy-last-queued-metric
pkg/proxy: add last-queued-timestamp metric
2 parents e494b07 + 2e1a884 commit a9f47c3

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

pkg/proxy/iptables/proxier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ func (proxier *Proxier) probability(n int) string {
504504
func (proxier *Proxier) Sync() {
505505
if proxier.healthzServer != nil {
506506
proxier.healthzServer.QueuedUpdate()
507+
metrics.SyncProxyRulesLastQueuedTimestamp.SetToCurrentTime()
507508
}
508509
proxier.syncRunner.Run()
509510
}

pkg/proxy/ipvs/proxier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset
810810
func (proxier *Proxier) Sync() {
811811
if proxier.healthzServer != nil {
812812
proxier.healthzServer.QueuedUpdate()
813+
metrics.SyncProxyRulesLastQueuedTimestamp.SetToCurrentTime()
813814
}
814815
proxier.syncRunner.Run()
815816
}

pkg/proxy/metrics/metrics.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ var (
125125
StabilityLevel: metrics.ALPHA,
126126
},
127127
)
128+
129+
// SyncProxyRulesLastQueuedTimestamp is the last time a proxy sync was
130+
// requested. If this is much larger than
131+
// kubeproxy_sync_proxy_rules_last_timestamp_seconds, then something is hung.
132+
SyncProxyRulesLastQueuedTimestamp = metrics.NewGauge(
133+
&metrics.GaugeOpts{
134+
Subsystem: kubeProxySubsystem,
135+
Name: "sync_proxy_rules_last_queued_timestamp_seconds",
136+
Help: "The last time a sync of proxy rules was queued",
137+
StabilityLevel: metrics.ALPHA,
138+
},
139+
)
128140
)
129141

130142
var registerMetricsOnce sync.Once
@@ -140,6 +152,7 @@ func RegisterMetrics() {
140152
legacyregistry.MustRegister(ServiceChangesPending)
141153
legacyregistry.MustRegister(ServiceChangesTotal)
142154
legacyregistry.MustRegister(IptablesRestoreFailuresTotal)
155+
legacyregistry.MustRegister(SyncProxyRulesLastQueuedTimestamp)
143156
})
144157
}
145158

pkg/proxy/winkernel/proxier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ func getHnsNetworkInfo(hnsNetworkName string) (*hnsNetworkInfo, error) {
736736
func (proxier *Proxier) Sync() {
737737
if proxier.healthzServer != nil {
738738
proxier.healthzServer.QueuedUpdate()
739+
metrics.SyncProxyRulesLastQueuedTimestamp.SetToCurrentTime()
739740
}
740741
proxier.syncRunner.Run()
741742
}

0 commit comments

Comments
 (0)