Skip to content

Commit

Permalink
Adding Metrics for Cluster Collector
Browse files Browse the repository at this point in the history
  • Loading branch information
yodigos committed Nov 5, 2024
1 parent f12c6ff commit 9cd0fe4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions cli/cmd/diagnose_util/profiling_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"os"
"path/filepath"
"strconv"
"sync"
)

Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions k8sutils/pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 1 addition & 5 deletions scheduler/controllers/collectorgroups/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -22,7 +18,7 @@ func NewClusterCollectorGroup(namespace string) *odigosv1.CollectorsGroup {
},
Spec: odigosv1.CollectorsGroupSpec{
Role: odigosv1.CollectorsGroupRoleClusterGateway,
CollectorOwnMetricsPort: ClusterCollectorDefaultOwnMetricsPort,
CollectorOwnMetricsPort: consts.OdigosClusterCollectorOwnTelemetryPortDefault,
},
}
}

0 comments on commit 9cd0fe4

Please sign in to comment.