Do not warn on target allocator config load for non-TA Prometheus configs#2157
Open
musa-asad wants to merge 2 commits into
Open
Do not warn on target allocator config load for non-TA Prometheus configs#2157musa-asad wants to merge 2 commits into
musa-asad wants to merge 2 commits into
Conversation
cad69ec to
e4be65d
Compare
4cc7024 to
c944da0
Compare
okankoAMZ
reviewed
Jun 17, 2026
c944da0 to
65c52cc
Compare
…figs A plain Prometheus config (top-level global:/scrape_configs:, no target_allocator: section) fails to parse as a prometheusreceiver.Config, which previously surfaced a misleading WARN at startup even though the Target Allocator was never requested. Gate the warning on the presence of a target_allocator: section: warn only when TA config was expected, otherwise log at DEBUG. Add regression tests covering the no-TA (no warn), malformed-TA (still warns) and section-detection cases.
65c52cc to
f601100
Compare
okankoAMZ
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A plain Prometheus deployment of the CloudWatch Agent (no Target Allocator) logs a misleading
WARN ... Could not load config for target allocator from fileat startup. No functional impact, but confusing because the user never requested a Target Allocator.Root cause:
createTargetAllocatorManagerunconditionally tries to parse the Prometheus config as aprometheusreceiver.Config. A plain config (global:/scrape_configs:at top level) fails strict unmarshal and fires a spurious WARN on every non-TA deployment.This change gates the warning on whether the config contains a
target_allocator:section: warn only when TA config was expected, otherwise log at Debug.Changes
plugins/inputs/prometheus/target_allocator.go:hasTargetAllocatorSection(filename)— checks if config has atarget_allocator:keyWarnwhentarget_allocator:section present,Debugotherwiseplugins/inputs/prometheus/target_allocator_test.go(new):TestCreateTargetAllocatorManager_NoTASection_NoWarn— no Warn for non-TA configTestCreateTargetAllocatorManager_MalformedTASection_Warns— genuine TA errors still warnTestHasTargetAllocatorSection— helper unit testTest Output
Before (stock agent image):
After (this branch):
Unit tests:
Verified on both Helm and EKS Add-On paths
The same agent binary runs on both paths. Verified the spurious WARN is absent on both:
Related