Skip to content

Append customer prometheus scrape configs - #1847

Merged
agarakan merged 3 commits into
replace-telegrapf-prom-pluginfrom
merge-prom-scrape-configs
Sep 5, 2025
Merged

Append customer prometheus scrape configs#1847
agarakan merged 3 commits into
replace-telegrapf-prom-pluginfrom
merge-prom-scrape-configs

Conversation

@agarakan

@agarakan agarakan commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

Description of the issue

When a customer provides prometheus scrape config relabel configs, we should not overwrite them. Additionally, the customer provided config must be processed last, after the default relabel config. This is to retain backwards compatibility given the new labels generated by the OTEL plugin for prometheus file-based service discovery (ECS Observer).

Description of changes

This change detects customer provided relabel configs and appends them to the dynamically configured relabel configs so that they can be processed after

ex:
Customer provides

		SourceLabels: model.LabelNames{"StartedBy"},
		TargetLabel:  "CustomStartedBy",
		Regex:        relabel.MustNewRegexp("(.*)"),

then the generated relabelConfig must look like this so that the Customer's action on StartedBy does not fail

...
Action:       relabel.Replace,
SourceLabels: model.LabelNames{"__meta_ecs_task_started_by"},
TargetLabel:  "StartedBy",
Regex:        relabel.MustNewRegexp("(.*)"),
...
Action:       relabel.Replace,
SourceLabels: model.LabelNames{"StartedBy"},
TargetLabel:  "CustomStartedBy",
Regex:        relabel.MustNewRegexp("(.*)"),

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 unit tests to verify customer scrape configs & all unit tests are passing

make test
make fmt
make fmt-sh
make lint

Requirements

Before commiting your code, please do the following steps.

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

Integration Tests

To run integration tests against this PR, add the ready for testing label.

@agarakan
agarakan requested a review from a team as a code owner September 4, 2025 18:38
Comment thread translator/translate/otel/receiver/prometheus/translator.go Outdated
@agarakan
agarakan force-pushed the merge-prom-scrape-configs branch from 350726b to 10ad471 Compare September 4, 2025 20:17
@agarakan
agarakan force-pushed the merge-prom-scrape-configs branch from 10ad471 to 210b509 Compare September 4, 2025 20:24
@agarakan
agarakan merged commit 42c1379 into replace-telegrapf-prom-plugin Sep 5, 2025
@agarakan
agarakan deleted the merge-prom-scrape-configs branch September 5, 2025 05:30
Comment thread translator/tocwconfig/tocwconfig_test.go
Comment thread translator/translate/otel/receiver/prometheus/translator.go
chadpatel pushed a commit to chadpatel/amazon-cloudwatch-agent that referenced this pull request Mar 19, 2026
Co-authored-by: Akansha Agarwal <agarakan@users.noreply.github.com>
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.

4 participants