Skip to content

Commit

Permalink
Update metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
annelau21 committed Jul 24, 2024
1 parent 4b6eaac commit d627075
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pkg/sloop/ingress/kubewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ type kubeWatcherImpl struct {
var (
newCrdClient = func(kubeCfg *rest.Config) (clientset.Interface, error) { return clientset.NewForConfig(kubeCfg) }
metricIngressGranularKubewatchcount = promauto.NewCounterVec(prometheus.CounterOpts{Name: "metric_ingress_event_kubewatchcount"}, []string{"namespace", "name", "kind", "reason", "type"})
metricIngressKubewatchcount = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchcount"}, []string{"kind", "namespace"})
metricIngressKubewatchbytes = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchbytes"}, []string{"kind", "namespace"})
metricIngressKubewatchcount = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchcount"}, []string{"kind", "watchtype"})
metricIngressKubewatchbytes = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchbytes"}, []string{"kind", "watchtype"})
metricCrdInformerStarted = promauto.NewGauge(prometheus.GaugeOpts{Name: "sloop_crd_informer_started"})
metricCrdInformerRunning = promauto.NewGauge(prometheus.GaugeOpts{Name: "sloop_crd_informer_running"})
)
Expand Down Expand Up @@ -334,14 +334,8 @@ func (i *kubeWatcherImpl) processUpdate(kind string, obj interface{}, watchResul
glog.V(common.GlogVerbose).Infof("Informer update: Name: %s, Namespace: %s, Reason: %s, Type: %s", involvedObject.Name, involvedObject.Namespace, eventInfo.Reason, eventInfo.Type)
}

metricIngressKubewatchCountWatchType := promauto.NewCounterVec(prometheus.CounterOpts{Name: fmt.Sprintf("sloop_ingress_kubewatchcount_%s", watchResult.WatchType.String())}, []string{"kind", "namespace"})
metricIngressKubewatchBytesWatchType := promauto.NewCounterVec(prometheus.CounterOpts{Name: fmt.Sprintf("sloop_ingress_kubewatchbytes_%s", watchResult.WatchType.String())}, []string{"kind", "namespace"})

metricIngressKubewatchcount.WithLabelValues(kind, kubeMetadata.Namespace).Inc()
metricIngressKubewatchbytes.WithLabelValues(kind, kubeMetadata.Namespace).Add(float64(len(resourceJson)))

metricIngressKubewatchCountWatchType.WithLabelValues(kind, kubeMetadata.Namespace).Inc()
metricIngressKubewatchBytesWatchType.WithLabelValues(kind, kubeMetadata.Namespace).Add(float64(len(resourceJson)))
metricIngressKubewatchcount.WithLabelValues(kind, watchResult.WatchType.String()).Inc()
metricIngressKubewatchbytes.WithLabelValues(kind, watchResult.WatchType.String()).Add(float64(len(resourceJson)))

glog.V(common.GlogVerbose).Infof("Informer update (%s) - Name: %s, Namespace: %s, ResourceVersion: %s", watchResult.WatchType, kubeMetadata.Name, kubeMetadata.Namespace, kubeMetadata.ResourceVersion)
watchResult.Payload = resourceJson
Expand Down

0 comments on commit d627075

Please sign in to comment.