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

feat(rules): when naming rules files use clear namespace separation #6482

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

diranged
Copy link

@diranged diranged commented Apr 6, 2024

Description

Ref: #3468

I ran into the same issue that @janotav did with this comment. I want to be able to identify metrics from the Thanos Ruler around rule execution and failures and narrow them down to the Namespace and PrometheusRule that they come from. The problem is the current naming pattern of $namespace-$rulename-$uid doesn't account for resources that have -'s in the names... ie, the following rule creates a file named my-namespace-some-rule-thing-xxx-xxx-xxx-xxx-xxx:

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: some-rule-thing
  namespace: my-namespace
  resourceVersion: "1146"
  uid: xxx-xxx-xxx-xxx-xxx

The string my-namespace-some-rule-thing-xxx-xxx-xxx-xxx-xxx cannot be parsed through metric relabelings because you cannot definitively pull out the namespace and name fields from the filename.

Type of change

  • 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

Due to #6284 - I was unable to fully test this locally.

Changelog entry

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

Use "--" to separate namespace, resource name and UID in Prometheus Rules filenames

@diranged diranged requested a review from a team as a code owner April 6, 2024 00:18
@diranged
Copy link
Author

diranged commented Apr 6, 2024

I see that these tests (https://github.com/prometheus-operator/prometheus-operator/actions/runs/8577200973/job/23509431752?pr=6482) failed - but I can't see how they relate to my change. Could they be flakey?

@simonpasquier
Copy link
Contributor

I agree that it'd be useful to reverse-parse the rule's namespace/name but if we do this, it should be documented somewhere. We could also discuss what should be used to separate namespace and name.
cc @prometheus-operator/prometheus-operator-reviewers

@diranged
Copy link
Author

@simonpasquier This is 3 weeks old now - thoughts on what we can do here to move this along?

@simonpasquier
Copy link
Contributor

I'm not 100% fan of the -- separator, could we use , to have a single char separator?

@diranged
Copy link
Author

diranged commented May 7, 2024

I don't really care what the separator is ... but I've just seen -- used in other places. I can't say I am a fan of a , in a filename.. either way though, it does actually work. If you want me to use a , that's fine with me I guess,..

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.

None yet

2 participants