Skip to content

Commit

Permalink
Create two seperate metrics - one with a watch type and the other wit…
Browse files Browse the repository at this point in the history
…hout
  • Loading branch information
annelau21 committed Jul 23, 2024
1 parent 81473b2 commit 4b6eaac
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/sloop/ingress/kubewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"sync/atomic"
"time"

"github.com/diegoholiveira/jsonlogic/v3"
"github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
Expand Down Expand Up @@ -77,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", "watchtype", "namespace"})
metricIngressKubewatchbytes = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchbytes"}, []string{"kind", "watchtype", "namespace"})
metricIngressKubewatchcount = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchcount"}, []string{"kind", "namespace"})
metricIngressKubewatchbytes = promauto.NewCounterVec(prometheus.CounterOpts{Name: "sloop_ingress_kubewatchbytes"}, []string{"kind", "namespace"})
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,8 +333,15 @@ func (i *kubeWatcherImpl) processUpdate(kind string, obj interface{}, watchResul
metricIngressGranularKubewatchcount.WithLabelValues(involvedObject.Namespace, involvedObject.Name, involvedObject.Kind, eventInfo.Reason, eventInfo.Type).Inc()
glog.V(common.GlogVerbose).Infof("Informer update: Name: %s, Namespace: %s, Reason: %s, Type: %s", involvedObject.Name, involvedObject.Namespace, eventInfo.Reason, eventInfo.Type)
}
metricIngressKubewatchcount.WithLabelValues(kind, watchResult.WatchType.String(), kubeMetadata.Namespace).Inc()
metricIngressKubewatchbytes.WithLabelValues(kind, watchResult.WatchType.String(), kubeMetadata.Namespace).Add(float64(len(resourceJson)))

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)))

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 4b6eaac

Please sign in to comment.