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 init container metrics #541

Closed

Conversation

thedebugger
Copy link
Contributor

What this PR does / why we need it:

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 #502

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 18, 2018

type cs_to_prom func(cs v1.ContainerStatus, ns string, pod string) string

pod_to_prom := func(p v1.Pod, fn_cs cs_to_prom, fn_ics cs_to_prom) string {
Copy link
Contributor Author

@thedebugger thedebugger Sep 18, 2018

Choose a reason for hiding this comment

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

in hindsight, refactoring this code in these methods may have made it more complex. But it makes changing things around a breeze and adding more pods/containers.

return sb.String()
}

mk_cs := func(name string, id int, ready bool, rc int32) v1.ContainerStatus {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i might need to change the name of these methods. let me know

@thedebugger
Copy link
Contributor Author

i'm going to test this in our cluster, but wanted to get it out to get feedback.

# HELP kube_pod_labels Kubernetes labels converted to Prometheus labels.
# TYPE kube_pod_labels gauge
# HELP kube_pod_container_status_ready Describes whether the containers readiness check succeeded.
# TYPE kube_pod_container_status_ready gauge
# HELP kube_pod_container_status_restarts_total The number of container restarts per container.
# TYPE kube_pod_container_status_restarts_total counter
# HELP kube_pod_init_container_status_restarts_total The number of init container restarts per container.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix the indentation?

@@ -382,21 +431,30 @@ func (pc *podCollector) collectPod(ch chan<- prometheus.Metric, p v1.Pod) {

var lastFinishTime float64

for _, cs := range p.Status.ContainerStatuses {
addGauge(descPodContainerInfo, 1,
collectContainerStatusMetric := func(cs v1.ContainerStatus, info *prometheus.Desc, waiting *prometheus.Desc, _waitingReason *prometheus.Desc, running *prometheus.Desc, terminated *prometheus.Desc, terminatedReason *prometheus.Desc, restarts *prometheus.Desc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about instead of passing in each metric description as arguments to the function, just passing in a single boolean e.g. isInitContainer. The function then decides which metric descriptions to use based on that. Should make this less verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it would reduce the params but not sure if that make it less verbose.

if init {
desc1 = init_metrics_desc1
...
}
else {
desc1 = metrics_desc1
...
}
addGauge(metrics_desc1, 1)

If i can make the change if you strongly feel about it

Copy link
Contributor

Choose a reason for hiding this comment

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

What do others think?

Copy link
Member

Choose a reason for hiding this comment

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

how about a third way? we pass a map instead of each single description, that way we have a single parameter and we can initialize the map just like the descriptions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I made the change.

@thedebugger
Copy link
Contributor Author

sorry, as I was rebasing it, the rebase changes got split across my commits. So I decided to squash them together for better readability. I'm going to test these changes in our cluster, but the PR is ready for final review. Let me know if you folks have more feedbacks.

@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 Dec 30, 2018
@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 Jan 29, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

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.

@brancz
Copy link
Member

brancz commented Feb 28, 2019

Sorry lost track of this.

/reopen

@k8s-ci-robot
Copy link
Contributor

@brancz: Reopened this PR.

In response to this:

Sorry lost track of this.

/reopen

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.

@k8s-ci-robot k8s-ci-robot reopened this Feb 28, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: thedebugger
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: brancz

If they are not already assigned, you can assign the PR to them by writing /assign @brancz in a comment when ready.

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

@brancz
Copy link
Member

brancz commented Feb 28, 2019

Sorry for the delay. This needs a rebase.

@tariq1890
Copy link
Contributor

@thedebugger would you be able to update this PR?

@thedebugger
Copy link
Contributor Author

@brancz @tariq1890 hey, i can try doing it but it is going to be a lot of work since the code has changed a lot. Could we have a smaller turn around time so that we can break this cycle? Let me know.

@brancz
Copy link
Member

brancz commented Apr 9, 2019

Usually turn around is very fast for this project, not sure why we dropped the ball here. Sorry!

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. 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.

kube state metrics doesn't report init container pod metrics
6 participants