Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apis/v1alpha1/allocation_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ package v1alpha1

type (
// AmazonCloudWatchAgentTargetAllocatorAllocationStrategy represent which strategy to distribute target to each collector
// +kubebuilder:validation:Enum=consistent-hashing
// +kubebuilder:validation:Enum=consistent-hashing;per-node
AmazonCloudWatchAgentTargetAllocatorAllocationStrategy string
)

const (
// AmazonCloudWatchAgentTargetAllocatorAllocationStrategyConsistentHashing targets will be consistently added to collectors, which allows a high-availability setup.
AmazonCloudWatchAgentTargetAllocatorAllocationStrategyConsistentHashing AmazonCloudWatchAgentTargetAllocatorAllocationStrategy = "consistent-hashing"

// AmazonCloudWatchAgentTargetAllocatorAllocationStrategyPerNode targets will be allocated to the collector running on the same node as the target.
// Targets without a resolvable node fall back to the configured fallback strategy (consistent-hashing).
AmazonCloudWatchAgentTargetAllocatorAllocationStrategyPerNode AmazonCloudWatchAgentTargetAllocatorAllocationStrategy = "per-node"
)
10 changes: 9 additions & 1 deletion apis/v1alpha1/amazoncloudwatchagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ type AmazonCloudWatchAgentTargetAllocator struct {
// +optional
Resources v1.ResourceRequirements `json:"resources,omitempty"`
// AllocationStrategy determines which strategy the target allocator should use for allocation.
// The current option is consistent-hashing.
// The options are consistent-hashing and per-node.
// +optional
AllocationStrategy AmazonCloudWatchAgentTargetAllocatorAllocationStrategy `json:"allocationStrategy,omitempty"`
// FilterStrategy determines how to filter targets before allocating them among the collectors.
Expand Down Expand Up @@ -381,6 +381,14 @@ type AmazonCloudWatchAgentTargetAllocatorPrometheusCR struct {
// ServiceMonitor's meta labels. The requirements are ANDed.
// +optional
ServiceMonitorSelector map[string]string `json:"serviceMonitorSelector,omitempty"`
// ScraperRole partitions ServiceMonitor/PodMonitor discovery across CloudWatch agents by the
// "cloudwatch.aws/scraper" annotation on the monitor CR. "cluster-scraper" selects only monitors
// annotated cloudwatch.aws/scraper: cluster-scraper; empty (default) selects only monitors that are
// not so annotated. This lets a heavy/singleton monitor be routed to the central cluster-scraper
// agent while all others stay on the per-node agent.
// +optional
// +kubebuilder:validation:Enum=cluster-scraper
ScraperRole string `json:"scraperRole,omitempty"`

@musa-asad musa-asad Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scraperRole has no enum validation, so a typo like cluster-scaper quietly falls back to the default role and that monitor gets scraped by nobody. The chart hardcodes the right value today, but could we add +kubebuilder:validation:Enum=cluster-scraper and regenerate the CRD?

}

// ScaleSubresourceStatus defines the observed state of the AmazonCloudWatchAgent's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (c *consistentHashingAllocator) handleCollectors(diff diff.Changes[*Collect
}
// Insert the new collectors
for _, i := range diff.Additions() {
c.collectors[i.Name] = NewCollector(i.Name)
c.collectors[i.Name] = NewCollector(i.Name, i.NodeName)
c.consistentHasher.Add(c.collectors[i.Name])
}

Expand Down
Loading