kube-state-metrics icon indicating copy to clipboard operation
kube-state-metrics copied to clipboard

Add support for InitContainer create/termination timestamps in Pod Metrics

Open darshanbm89 opened this issue 9 months ago • 8 comments

What would you like to be added: Expose the init containers start/terminated timestamps

Why is this needed: We are trying to monitor the container start latencies and observed that kube_pod_container_state_started and kube_pod_container_status_last_terminated_timestamp does not provide information on the init containers.

Describe the solution you'd like Expose the epoch time stamps of the init-containers creation and termination events

Additional context

darshanbm89 avatar Mar 12 '25 07:03 darshanbm89

cc @CatherineF-dev /triage accepted /help

richabanker avatar Mar 20 '25 16:03 richabanker

@richabanker: This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to this:

cc @CatherineF-dev /triage accepted /help

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-sigs/prow repository.

k8s-ci-robot avatar Mar 20 '25 16:03 k8s-ci-robot

Hi, could you share some use cases of monitoring these short-lived containers?

CatherineF-dev avatar Mar 22 '25 14:03 CatherineF-dev

I'm not the original asker, but I also want to monitor the start time of init containers.

In my case it's because we're using the new Kubernetes Sidecar containers https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/ which are implemented as long running init containers.

I'm trying to monitor when each sidecar is started and how long it takes for it to become ready, but those metrics only exist for "normal" containers

drolando-stripe avatar Mar 25 '25 00:03 drolando-stripe

I see. We have added tag help-wanted. Feel free to create a pull request.

CatherineF-dev avatar Mar 25 '25 00:03 CatherineF-dev

Hey @CatherineF-dev , Apologies. I lost track of this issue and just saw your response.

We are interested in these metrics for a couple of reason

  1. We are interested to understand the overhead these init containers are causing during the pod startup.
  2. There are some long running init containers as @drolando-stripe mentioned.

Thanks Orlando for taking the look and creating the PR

darshanbm89 avatar Jul 24 '25 06:07 darshanbm89

Hi @darshanbm89 , Is this issue fixed by Orlando's PR or it's still available for me to work on?

onasser1 avatar Aug 07 '25 08:08 onasser1

@onasser1 The author seems to have dropped working on the linked PR and haven't responded in a while, so please feel free to pick this up, thank you.

rexagod avatar Aug 27 '25 01:08 rexagod