Skip to content

Commit

Permalink
fix: Ensure correct exporter_type label for each service group
Browse files Browse the repository at this point in the history
  • Loading branch information
pcfreak30 committed Dec 29, 2024
1 parent 532df8c commit 44a2f88
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/promster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,24 @@ func getScrapeTargets(ctx context.Context, registry *etcdregistry.EtcdRegistry)
// Get or create service group
sg, exists := groupedNodes[groupKey]
if !exists {
// Merge group common labels with node labels
// Create a new label map for this specific group
labels := make(map[string]string)

// First add common labels from the group
for k, v := range group.Spec.CommonLabels {
labels[k] = v
}

// Then add this specific node's labels
for k, v := range node.Labels {
labels[k] = v
// Skip exporter_type from node labels
if k != "exporter_type" {
labels[k] = v
}
}

// Ensure exporter_type matches this node's type
labels["exporter_type"] = node.ExporterType

// Include exporter type in the job name
jobName := fmt.Sprintf("%s-%s", serviceName, node.ExporterType)
Expand Down

0 comments on commit 44a2f88

Please sign in to comment.