Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1810725: Fix kube_proxy metrics #118

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions pkg/network/node/metrics.go
Expand Up @@ -12,11 +12,11 @@ import (
"sync"
"time"

"github.com/prometheus/client_golang/prometheus"

utilruntime "k8s.io/apimachinery/pkg/util/runtime"

"github.com/openshift/sdn/pkg/network/node/ovs"
"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"
)

const (
Expand All @@ -36,35 +36,35 @@ const (
)

var (
OVSFlows = prometheus.NewGauge(
prometheus.GaugeOpts{
OVSFlows = metrics.NewGauge(
&metrics.GaugeOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: OVSFlowsKey,
Help: "Number of Open vSwitch flows",
},
)

ARPCacheAvailableEntries = prometheus.NewGauge(
prometheus.GaugeOpts{
ARPCacheAvailableEntries = metrics.NewGauge(
&metrics.GaugeOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: ARPCacheAvailableEntriesKey,
Help: "Number of available entries in the ARP cache",
},
)

PodIPs = prometheus.NewGauge(
prometheus.GaugeOpts{
PodIPs = metrics.NewGauge(
&metrics.GaugeOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: PodIPsKey,
Help: "Number of allocated pod IPs",
},
)

PodOperationsErrors = prometheus.NewCounterVec(
prometheus.CounterOpts{
PodOperationsErrors = metrics.NewCounterVec(
&metrics.CounterOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: PodOperationsErrorsKey,
Expand All @@ -73,8 +73,8 @@ var (
[]string{"operation_type"},
)

PodOperationsLatency = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
PodOperationsLatency = metrics.NewSummaryVec(
&metrics.SummaryOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: PodOperationsLatencyKey,
Expand All @@ -83,8 +83,8 @@ var (
[]string{"operation_type"},
)

VnidNotFoundErrors = prometheus.NewCounter(
prometheus.CounterOpts{
VnidNotFoundErrors = metrics.NewCounter(
&metrics.CounterOpts{
Namespace: SDNNamespace,
Subsystem: SDNSubsystem,
Name: VnidNotFoundErrorsKey,
Expand All @@ -105,12 +105,12 @@ var registerMetrics sync.Once
// Register all node metrics.
func RegisterMetrics() {
registerMetrics.Do(func() {
prometheus.MustRegister(OVSFlows)
prometheus.MustRegister(ARPCacheAvailableEntries)
prometheus.MustRegister(PodIPs)
prometheus.MustRegister(PodOperationsErrors)
prometheus.MustRegister(PodOperationsLatency)
prometheus.MustRegister(VnidNotFoundErrors)
legacyregistry.MustRegister(OVSFlows)
legacyregistry.MustRegister(ARPCacheAvailableEntries)
legacyregistry.MustRegister(PodIPs)
legacyregistry.MustRegister(PodOperationsErrors)
legacyregistry.MustRegister(PodOperationsLatency)
legacyregistry.MustRegister(VnidNotFoundErrors)
})
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/openshift-sdn/proxy.go
Expand Up @@ -32,7 +32,7 @@ import (
sdnproxy "github.com/openshift/sdn/pkg/network/proxy"
"github.com/openshift/sdn/pkg/network/proxyimpl/hybrid"
"github.com/openshift/sdn/pkg/network/proxyimpl/unidler"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/component-base/metrics/legacyregistry"
"k8s.io/klog"
)

Expand Down Expand Up @@ -217,7 +217,7 @@ func (sdn *OpenShiftSDN) runProxy(waitChan chan<- bool) {
mux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", sdn.ProxyConfig.Mode)
})
mux.Handle("/metrics", prometheus.Handler())
mux.Handle("/metrics", legacyregistry.Handler())
go utilwait.Until(func() {
err := http.ListenAndServe(sdn.ProxyConfig.MetricsBindAddress, mux)
if err != nil {
Expand Down