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

fix issues related to prometheus relabel configs when target allocator is enabled #1711

Closed
wants to merge 2 commits into from

Conversation

anunarapureddy
Copy link
Member

@anunarapureddy anunarapureddy commented May 4, 2023

Related to following issues: #1623, #1622, #958

Cause:

The issue manifests itself in two scenarios.

  1. First, when Prometheus adds a default value of the replacement key with $1, the collector interprets it as an environment variable substitution and resolves it to an empty string. When the configMap is built by the operator, the unmarshalling logic calls the Prometheus relabel config validation logic (relabel.go), which includes the additional defaults, including the $1 replacement field, appended to the original Prometheus configuration. Upon initialization, the collector pod loads the configMap and interprets $1 as an environment variable, leading to its replacement with an empty string. As a result, the same Prometheus relabel config validation logic fails when the config is unmarshalled in the collector code, as the replacement key is now replaced with an empty string due to env var substitution.

  2. Second, when Prometheus configuration explicitly contains $$ for labelmap, labeldrop, labelkeep or other Prometheus actions that undergo regex validation in the prometheus validation code (relabel.go), the validation of the regex will fail.

Resolution:

  1. For the first scenario, the solution involved explicitly escaping the default '$' character in the replacement key while building the configMap. This was done by replacing all occurrences of '$' with ‘$$’. Upon initialization, the collector pod loads the ConfigMap and resolves ‘$$’ as ‘$’, thus ensuring that the metric relabel config validation in Prometheus passes successfully when the configuration is unmarshalled in the collector code.

  2. For the second scenario, the approach involved replacing all occurrences of '$$' with the string 'DOUBLE_DOLLAR' and '$' with the string 'SINGLE_DOLLAR' right before unmarshalling the Prometheus config while creating the configMap. After unmarshalling, the values were reset to their original values. This solution ensured that Prometheus regex validation succeeds.

@anunarapureddy anunarapureddy requested a review from a team as a code owner May 4, 2023 23:31
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 4, 2023

CLA Missing ID CLA Not Signed

@anunarapureddy anunarapureddy marked this pull request as draft May 4, 2023 23:39
@anunarapureddy anunarapureddy marked this pull request as ready for review May 5, 2023 00:43
Anusha Narapureddy and others added 2 commits May 4, 2023 17:52
#958

updated comments and fixed EOL issues

updated comments and fixed EOL issues

  Author:    Anusha Narapureddy <anusha_narapureddy@apple.com>
@anunarapureddy anunarapureddy closed this by deleting the head repository May 5, 2023
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.

None yet

1 participant