From 9cd0fe4afdde895185e178641e694cd969e0c448 Mon Sep 17 00:00:00 2001 From: yodigos Date: Tue, 5 Nov 2024 14:10:06 +0200 Subject: [PATCH] Adding Metrics for Cluster Collector --- cli/cmd/diagnose_util/profiling_util.go | 5 +++-- k8sutils/pkg/consts/consts.go | 4 ++++ scheduler/controllers/collectorgroups/cluster.go | 6 +----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cli/cmd/diagnose_util/profiling_util.go b/cli/cmd/diagnose_util/profiling_util.go index 730908538..a12bbf964 100644 --- a/cli/cmd/diagnose_util/profiling_util.go +++ b/cli/cmd/diagnose_util/profiling_util.go @@ -11,6 +11,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os" "path/filepath" + "strconv" "sync" ) @@ -204,9 +205,9 @@ func collectMetrics(ctx context.Context, client *kube.Client, odigosNamespace st func captureMetrics(ctx context.Context, client *kube.Client, podName string, namespace string, metricFile *os.File, collectorRole consts.CollectorRole) error { portNumber := "" if collectorRole == consts.CollectorsRoleClusterGateway { - portNumber = "8888" + portNumber = strconv.Itoa(int(consts.OdigosClusterCollectorOwnTelemetryPortDefault)) } else if collectorRole == consts.CollectorsRoleNodeCollector { - portNumber = "55682" + portNumber = strconv.Itoa(int(consts.OdigosNodeCollectorOwnTelemetryPortDefault)) } else { return nil } diff --git a/k8sutils/pkg/consts/consts.go b/k8sutils/pkg/consts/consts.go index 618dda30f..c9d0ecbf2 100644 --- a/k8sutils/pkg/consts/consts.go +++ b/k8sutils/pkg/consts/consts.go @@ -21,6 +21,10 @@ const ( OdigosClusterCollectorCollectorGroupName = OdigosClusterCollectorDeploymentName OdigosClusterCollectorConfigMapKey = "collector-conf" + + // The cluster gateway collector runs as a deployment and the pod is exposed as a service. + // Thus it cannot collide with other ports on the same node, and we can use an handy default port. + OdigosClusterCollectorOwnTelemetryPortDefault = int32(8888) ) const ( diff --git a/scheduler/controllers/collectorgroups/cluster.go b/scheduler/controllers/collectorgroups/cluster.go index 864e7c590..f9e9dfe63 100644 --- a/scheduler/controllers/collectorgroups/cluster.go +++ b/scheduler/controllers/collectorgroups/cluster.go @@ -6,10 +6,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// The cluster gateway collector runs as a deployment and the pod is exposed as a service. -// Thus it cannot collide with other ports on the same node, and we can use an handy default port. -const ClusterCollectorDefaultOwnMetricsPort = 8888 - func NewClusterCollectorGroup(namespace string) *odigosv1.CollectorsGroup { return &odigosv1.CollectorsGroup{ TypeMeta: metav1.TypeMeta{ @@ -22,7 +18,7 @@ func NewClusterCollectorGroup(namespace string) *odigosv1.CollectorsGroup { }, Spec: odigosv1.CollectorsGroupSpec{ Role: odigosv1.CollectorsGroupRoleClusterGateway, - CollectorOwnMetricsPort: ClusterCollectorDefaultOwnMetricsPort, + CollectorOwnMetricsPort: consts.OdigosClusterCollectorOwnTelemetryPortDefault, }, } }