-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support filtering label allowlist by "*" #1823
Conversation
Welcome @rexagod! |
.gitignore
Outdated
@@ -37,6 +37,7 @@ _testmain.go | |||
|
|||
*.iml | |||
.idea/ | |||
.run/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is not generated by ksm, it shouldn't be added to the gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be a pretty useful feature, thank you for taking it up @rexagod.
There are a couple of things that would need to be done though before merging this effort:
- Update the description of the command to explain the new behavior:
kube-state-metrics/pkg/options/options.go
Line 110 in a3a509a
o.flags.Var(&o.LabelsAllowList, "metric-labels-allowlist", "Comma-separated list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...)'. A single '*' can be provided per resource instead to allow any labels, but that has severe performance implications (Example: '=pods=[*]').") - Add a new test for the
all
wildcard inkube-state-metrics/pkg/options/types_test.go
Line 197 in a3a509a
func TestLabelsAllowListSet(t *testing.T) { - Test that the
all
wildcard really returns label metrics for all the resources. This could be an e2e test like the one we have to test the--resources
option in or a unit test in for the builder:kube-state-metrics/tests/e2e/main_test.go
Line 247 in a3a509a
func TestDefaultCollectorMetricsAvailable(t *testing.T) {
internal/store/builder.go
Outdated
@@ -202,7 +202,16 @@ func (b *Builder) WithAllowAnnotations(annotations map[string][]string) { | |||
// WithAllowLabels configures which labels can be returned for metrics | |||
func (b *Builder) WithAllowLabels(labels map[string][]string) { | |||
if len(labels) > 0 { | |||
b.allowLabelsList = labels | |||
// "all" takes precedence over other specifications | |||
if allowedLabels, ok := labels["all"]; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use *
instead of all
?
730713f
to
1919a94
Compare
Ready for review. |
Support filtering label allowlist by "*", which will expand to the enabled resources, while infering their values based on its value(s). Signed-off-by: Pranshu Srivastava <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold
Thanks!
Awesome, great stuff @rexagod! /lgtm /unhold |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dgrisonnet, mrueg, rexagod The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it: Support filtering label allowlist by "*", which will expand to the enabled resources, while inferring their values based on its value(s).
How does this change affect the cardinality of KSM: No change.
Which issue(s) this PR fixes: Fixes #1815.