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

Bound the number of labels of all metrics #1124

Closed
dgrisonnet opened this issue Apr 16, 2020 · 5 comments · Fixed by #1125
Closed

Bound the number of labels of all metrics #1124

dgrisonnet opened this issue Apr 16, 2020 · 5 comments · Fixed by #1125
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@dgrisonnet
Copy link
Member

Is this a BUG REPORT or FEATURE REQUEST?:

/kind feature

This proposal is originating from this discussion #1102.

Motivation:

More and more users want to expose high cardinality metrics; however, it comes with great costs for the default configuration of kube-state-metrics.

#941
#1047

Moreover, some of these metrics (for example: Kubernetes labels or annotations) can generate an unbound amount of labels. Thus, it is possible for these metrics to produce an unlimited number of series leading to some severe security issues.

Goals:

Make it possible to safely register metrics having an unbound amount of labels.

Non-Goals:

Set the sane defaults

Proposal:

In order to safely register metrics having an unbound amount of labels, a feature gates mechanism where labels could be allowed per metrics can be used.

In order to bound the number of labels of all metrics, this gate will only allow labels instead of allowing and denying. The reason behind this is that a deny mechanism would mean that everything is allowed except what is specifically denied. In the case of metrics with an unbound number of labels that would still result in an unbound number of labels.

By default, sensitive metrics will have all their labels denied and it will be left to the users to specify which labels they want to use. This will allow to only expose metrics having a limited number of labels and thus prevent some security issues.

The gates will have the following pattern:

Metric Default value
"_labels$" []
"_annotations$" []
others [*]

Users will then be able to allow specific labels the following way:

--labels-allow-list="kube_job_labels=[label1,label2],kube_node_labels=[label1]"
@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 16, 2020
@jw-s
Copy link
Contributor

jw-s commented Apr 17, 2020

--labels-allow-list="kube_job_labels=[label1,label2],kube_node_labels=[label1]"
@dgrisonnet Do we already have a flag type defined for this?

@dgrisonnet
Copy link
Member Author

As far as I know, we don't have such a type. The existing ones are defined here: types.go. Having a look into this file might help you write the new flag type.

@jw-s
Copy link
Contributor

jw-s commented Apr 18, 2020

@dgrisonnet here is a rough wip of the solution #1125 , i'm not really happy with the flag. WDYT, any suggestions? Regex or tokenizer?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 20, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants