Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target Allocator Support for Telegraf Based Prometheus Receiver #1394

Merged
merged 29 commits into from
Nov 14, 2024

Conversation

okankoAMZ
Copy link
Contributor

@okankoAMZ okankoAMZ commented Oct 15, 2024

Description of the issue

We have a new tool called Target Allocator, which provides scrape configs. These changes allows telegraf based prometheus receiver to pull scrape configs from Target Allocator endpoint.

There was a bug on config returning if TA exist instead of does not exist on this PR(#1390) thus reverted and created this one.

Description of changes

  • Added Target Allocator Manager(TAM), based on contrib version but with a wrapper
  • TAM is now included and checked during initial and reload configs to make sure TA is enabled or disabled.
  • When TA is enabled the TAM will provide the prometheus config to telegraf prometheus receiver directly. (without a file read)

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  • Added some unit tests which pass
  • Manually tested where I can see metrics on CloudWatch when Agent is deployed.

CloudWatch Metrics ScreenShot

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@okankoAMZ okankoAMZ requested a review from a team as a code owner October 15, 2024 17:38
go.mod Outdated Show resolved Hide resolved
plugins/inputs/prometheus/start.go Outdated Show resolved Hide resolved
plugins/inputs/prometheus/start.go Show resolved Hide resolved
plugins/inputs/prometheus/start.go Outdated Show resolved Hide resolved
plugins/inputs/prometheus/start.go Outdated Show resolved Hide resolved
plugins/inputs/prometheus/target_allocator.go Outdated Show resolved Hide resolved
jefchien
jefchien previously approved these changes Oct 17, 2024
Paramadon
Paramadon previously approved these changes Oct 22, 2024
Copy link
Contributor

@Paramadon Paramadon left a comment

Choose a reason for hiding this comment

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

Logic looks good just need some more error/path handling and I would also like to see more comments in the code to explain key decision points for example when modifying the configuration.

@Paramadon Paramadon self-requested a review October 22, 2024 15:57
@okankoAMZ okankoAMZ changed the title Target Allocator Support for Native Prometheus Receiver Target Allocator Support for Telegraf Based Prometheus Receiver Oct 24, 2024
@okankoAMZ okankoAMZ changed the base branch from target-allocator to main October 30, 2024 14:40
@okankoAMZ okankoAMZ dismissed stale reviews from musa-asad, Paramadon, and jefchien October 30, 2024 14:40

The base branch was changed.

plugins/inputs/prometheus/target_allocator.go Outdated Show resolved Hide resolved
func (tam *TargetAllocatorManager) AttachReloadConfigHandler(handler func(config *promconfig.Config)) {
tam.reloadConfigHandler = handler
}
func (tam *TargetAllocatorManager) reloadConfigTicker() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The function name sounds like it's reloading a ticker, but it's actually creating a reload ticker.

plugins/inputs/prometheus/target_allocator.go Outdated Show resolved Hide resolved
musa-asad
musa-asad previously approved these changes Nov 12, 2024
jefchien
jefchien previously approved these changes Nov 12, 2024
@okankoAMZ okankoAMZ dismissed stale reviews from jefchien and musa-asad via 8b7824d November 13, 2024 15:58
@okankoAMZ okankoAMZ force-pushed the ta-collector branch 2 times, most recently from fd1f5b2 to 48aaa7f Compare November 13, 2024 18:00
@sky333999
Copy link
Contributor

Approving from prior reviews

@okankoAMZ okankoAMZ merged commit 1e78609 into main Nov 14, 2024
6 checks passed
@okankoAMZ okankoAMZ deleted the ta-collector branch November 14, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants