Skip to content

feat: add support for UTF8 labels and rules#7637

Merged
slashpai merged 3 commits intoprometheus-operator:mainfrom
slashpai:utf-8
Oct 6, 2025
Merged

feat: add support for UTF8 labels and rules#7637
slashpai merged 3 commits intoprometheus-operator:mainfrom
slashpai:utf-8

Conversation

@slashpai
Copy link
Contributor

Related-to #7362

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.

feat: add support for UTF8 labels and rules

@slashpai
Copy link
Contributor Author

Working on to support in rules

@slashpai slashpai marked this pull request as ready for review June 25, 2025 17:26
@slashpai slashpai requested a review from a team as a code owner June 25, 2025 17:26
@slashpai
Copy link
Contributor Author

I am adding a e2e test as well

@slashpai slashpai marked this pull request as draft June 26, 2025 04:22
@slashpai
Copy link
Contributor Author

more changes needed realised after testing e2e locally

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

⚠️ Comment superseded by #7362 (comment) ⚠️

Options

  1. Have a global lock on model.NameValidationScheme but it's ugly and brittle.
  2. Expose a CLI flag in the operator to choose between legacy and utf8 validation.
  3. Declare that we only support Prometheus > 3.x from now on.

1 and 2 don't solve the issue of validations in the CRD. Option 3 is a bit extreme.

A middle ground could be:

  • We disable all validations on label names in the CRDs (it's the only way we can support UTF-8 label names).
  • We set model.NameValidationScheme = model.UTF8Validation in the operator.
  • For 3.x versions, the operator doesn't need to perform additional validation because values are always valid UTF-8 strings.
  • For 2.x, the operator performs additional validation and reject resources (be it Prometheus, PrometheusRule, ServiceMonitor, ...) which define non-legacy label names.
    • It means that we duplicate the logic from prometheus/common but I see no other way to deal with it.
    • The user experience degrades for 2.x setups because the API doesn't prevent invalid inputs anymore but at the same time, it encourages migration to 3.x.
    • We could think about an option to translate the label names into a legacy-compliant scheme (e.g. replacing invalid characters by "_") instead of rejecting resources but I'm not sure it's worth the effort.
  • The admission webhook could have a new option to select which validation scheme it uses (it's straightforward to implement).

Of course, we'd need end-to-end tests to verify the different scenarios.

In parallel we also need to think about Alertmanager and Thanos Ruler...

@slashpai
Copy link
Contributor Author

With prometheus/prometheus@0a40df3#diff-b8c18b1e4cc9c9beec1598127742d0a82c9ffb2805996e1887aaa1021ed90587 it looks to be easier to have the option available in operator so current change is based on that

@slashpai
Copy link
Contributor Author

TODO: relabel validations needed to be updated with logic as in prometheus

@simonpasquier
Copy link
Contributor

it looks to be easier to have the option available in operator so current change is based on that

IIUC the operator would need to gate on the Prometheus version (for any version not having the ability to configure the validation scheme, the option wouldn't apply and the operator needs to compute the validation scheme applying to the version).
Anyway this is way nicer than before.

@simonpasquier
Copy link
Contributor

So we have a chicken-and-egg problem because the current CRDs don't allow for utf-8 labels. I'm fine merging this PR as it is and have the end-to-end tests in the follow-up PR which relaxes the validations.

@slashpai slashpai force-pushed the utf-8 branch 3 times, most recently from a952662 to 1c64352 Compare October 3, 2025 11:02
@slashpai slashpai force-pushed the utf-8 branch 2 times, most recently from 2fc72fa to 831e0bb Compare October 3, 2025 13:07
simonpasquier
simonpasquier previously approved these changes Oct 3, 2025
simonpasquier
simonpasquier previously approved these changes Oct 3, 2025
@slashpai
Copy link
Contributor Author

slashpai commented Oct 6, 2025

I was finally able to fix my podman issue to test the change locally as depending CI was taking time, I am debugging the root cause for failure locally

for admission webhook default is legacy validation

Assissted-By: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@slashpai
Copy link
Contributor Author

slashpai commented Oct 6, 2025

It should pass now it was issue of promql query it should have been {"cluster.app_info:5m"} 🤦🏻‍♀️

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

thanks!

@slashpai slashpai merged commit cc19d0e into prometheus-operator:main Oct 6, 2025
36 of 38 checks passed
slashpai added a commit to slashpai/prometheus-operator that referenced this pull request Oct 6, 2025
Follow-up from prometheus-operator#7637 to complete the UTF8 support for labels

Related-to: prometheus-operator#7362

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this pull request Oct 6, 2025
Follow-up from prometheus-operator#7637 to complete the UTF8 support for labels

Related-to: prometheus-operator#7362

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this pull request Oct 7, 2025
Follow-up from prometheus-operator#7637 to complete the UTF8 support for labels

Related-to: prometheus-operator#7362

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this pull request Oct 7, 2025
Follow-up from prometheus-operator#7637 to complete the UTF8 support for labels

Related-to: prometheus-operator#7362

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
slashpai added a commit to slashpai/prometheus-operator that referenced this pull request Oct 7, 2025
Follow-up from prometheus-operator#7637 to complete the UTF8 support for labels

Related-to: prometheus-operator#7362

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@simonpasquier simonpasquier mentioned this pull request Oct 7, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants