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

add kube_*_annotations metrics #770

Merged
merged 1 commit into from
Jun 26, 2019
Merged

add kube_*_annotations metrics #770

merged 1 commit into from
Jun 26, 2019

Conversation

qw1mb0
Copy link
Contributor

@qw1mb0 qw1mb0 commented May 28, 2019

What this PR does / why we need it:
In this PR, a new metrics kube_*_annotations is added for all Kubernetes objects, in which will be a list of all the annotation of object. This functionality is very necessary for the ability to display data on the basis of annotations in grafana and the construction of the rules, alerts.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #746

@k8s-ci-robot
Copy link
Contributor

Welcome @qw1mb0!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 28, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 28, 2019
@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 28, 2019

And I would like to ask for advice, perhaps it is worth removing from the annotation the mention of kubernetes_io_last_applied_configuration? If so, can you tell me how you can do this?
Thank you very much in advance!

@brancz
Copy link
Member

brancz commented May 28, 2019

I think we've recently had a similar case to this. I'm trying to understand why this is not a real field on the deployment? This being an annotation doesn't make me feel like this should be a stable metric.

@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 28, 2019

This metric appears only when manually managing deployment in kubernetes using the kubectl edit deploy app.

Then the metric will look like this:

kube_deployment_annotations{annotation_deployment_kubernetes_io_revision="1",annotation_kubectl_kubernetes_io_last_applied_configuration="{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"my-nginx","namespace":"default"},"spec":{"replicas":2,"selector":{"matchLabels":{"run":"my-nginx"}},"template":{"metadata":{"labels":{"run":"my-nginx"}},"spec":{"containers":[{"image":"nginx","lifecycle":{"preStop":{"exec":{"command":["/bin/sh","-c","sleep 90; nginx -s quit"]}}},"name":"my-nginx","ports":[{"containerPort":80}]}]}}}} ",deployment="my-nginx",instance="10.244.1.90:8443",job="kube-state-metrics",namespace="default",scrape_endpoint="main"}

@brancz
Copy link
Member

brancz commented May 28, 2019

hmm... maybe someone from sig cli or sig apps could explain why this is not a real field, maybe it's a prospect for an objectmeta field?

@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 28, 2019

This summary is used for the patch: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#merge-patch-calculation

Now we can leave this annotation. Can I add this label to all other resources?

@brancz
Copy link
Member

brancz commented May 28, 2019

Could you add examples of the annotations you intend to use in the tests? Because I don't think the result that you are currently producing is what you are looking for, as you can't do math with label values.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 28, 2019
@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 28, 2019

I added annotations to deployment_test.go in this commit: 44b0763

docs/deployment-metrics.md Outdated Show resolved Hide resolved
@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 28, 2019

Can I make a similar metric for all other resources now?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 29, 2019
Copy link
Contributor

@zuzzas zuzzas left a comment

Choose a reason for hiding this comment

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

Some things stood out.

@@ -6,3 +6,4 @@
| kube_certificatesigningrequest_condition | Gauge | `certificatesigningrequest`=&lt;certificatesigningrequest-name&gt; <br> `condition`=&lt;approved\|denied&gt; | STABLE |
| kube_certificatesigningrequest_labels | Gauge | `certificatesigningrequest`=&lt;certificatesigningrequest-name&gt;| STABLE |
| kube_certificatesigningrequest_cert_length | Gauge | `certificatesigningrequest`=&lt;certificatesigningrequest-name&gt;| STABLE |
| kube_certificatesigningrequest_labels | Guage | `annotation_CSR_ANNOTATION`=&lt;CSR_ANNOTATION&gt; <br> `certificatesigningrequest`=&lt;certificatesigningrequest-name&gt; | STABLE |
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems incorrect.

@@ -32,6 +32,9 @@ var (
descCSRLabelsHelp = "Kubernetes labels converted to Prometheus labels."
descCSRLabelsDefaultLabels = []string{"certificatesigningrequest"}

descCSRAnnotationsName = "kube_certificatesigningrequest_annotations"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind adding a variable that is only used once? Useless indirection creates confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

That applies to all such changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 29, 2019
@qw1mb0
Copy link
Contributor Author

qw1mb0 commented May 29, 2019

@brancz I added the metric kube _ * _ annotations for all resources, everything works correctly on the test cluster and the tests were successful. What do you think about this PR?

@qw1mb0 qw1mb0 changed the title add kube_deployment_annotations metric add kube_*_annotations metrics May 29, 2019
Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

Additionally to skipping the pod annotations, could we mark all of these as experimental? I would like to be able to remove them if there is a cardinality problem with any of them.

@@ -40,3 +40,4 @@
| kube_pod_spec_volumes_persistentvolumeclaims_info | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; | STABLE |
| kube_pod_spec_volumes_persistentvolumeclaims_readonly | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `volume`=&lt;volume-name&gt; <br> `persistentvolumeclaim`=&lt;persistentvolumeclaim-claimname&gt; | STABLE |
| kube_pod_status_scheduled_time | Gauge | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | STABLE |
| kube_pod_annotations | Gauge | `annotation_POD_ANNOTATION`=&lt;POD_ANNOTATION&gt; <br> `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; | STABLE |
Copy link
Member

Choose a reason for hiding this comment

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

this was deemed to be too high cardinality previously, it needs more discussion I'd say, let's not add this here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good. I deleted the metric for the pods

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 8, 2019
@qw1mb0
Copy link
Contributor Author

qw1mb0 commented Jun 20, 2019

/retest

@k8s-ci-robot
Copy link
Contributor

@qw1mb0: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@qw1mb0
Copy link
Contributor Author

qw1mb0 commented Jun 20, 2019

/assign @tariq1890

@tariq1890
Copy link
Contributor

Can you rebase this PR?

@qw1mb0
Copy link
Contributor Author

qw1mb0 commented Jun 24, 2019

Can you rebase this PR?

done

Copy link
Contributor

@tariq1890 tariq1890 left a comment

Choose a reason for hiding this comment

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

LGTM to me. I'll defer to @brancz for the final decision. Thanks for your contribution :)!

/lgtm
/approve
/hold

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 25, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qw1mb0, tariq1890

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2019
@brancz
Copy link
Member

brancz commented Jun 26, 2019

lgtm :)

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 26, 2019
@k8s-ci-robot k8s-ci-robot merged commit f24d831 into kubernetes:master Jun 26, 2019
@diemus
Copy link

diemus commented Jul 12, 2019

when will this become a stable version?

@tariq1890
Copy link
Contributor

tariq1890 commented Jul 12, 2019

@diemus Thanks for checking in! We will wait for a period of atleast 10 7 days from the date of publishing the release candidate. If there are no issues/bugs reported within that window, we will publish a stable release.

Until then, please feel free to test this feature with the 1.7.0-rc1 build and let us know if you face issues :).

@brancz
Copy link
Member

brancz commented Jul 12, 2019

Small correction: 7 days is the normal wait time to promote from release candidate to final release.

@tariq1890
Copy link
Contributor

Thanks @brancz ! I'll amend my previous comment.

@lilic
Copy link
Member

lilic commented Jul 12, 2019

@tariq1890 @brancz should we add this info about the release process in the docs somewhere or do we have it already?

@brancz
Copy link
Member

brancz commented Jul 12, 2019

it is not as far as I can tell, please feel free to add it to the RELEASE.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New metric for deployment revision
7 participants