Skip to content

feat: add init container state_started and last_terminated_timestamp metrics#2904

Open
maksimp13 wants to merge 3 commits intokubernetes:mainfrom
maksimp13:feature/add-init-container-state-started-last-terminated-metrics
Open

feat: add init container state_started and last_terminated_timestamp metrics#2904
maksimp13 wants to merge 3 commits intokubernetes:mainfrom
maksimp13:feature/add-init-container-state-started-last-terminated-metrics

Conversation

@maksimp13
Copy link
Copy Markdown

@maksimp13 maksimp13 commented Mar 20, 2026

What this PR does

Closes #2627

Adds two new init container metrics, equivalent to their existing regular container counterparts:

New metric Stability Mirrors
kube_pod_init_container_state_started ALPHA kube_pod_container_state_started (STABLE)
kube_pod_init_container_status_last_terminated_timestamp ALPHA kube_pod_container_status_last_terminated_timestamp (ALPHA)

kube_pod_init_container_state_started emits the start time (unix timestamp) for init containers currently in Running or Terminated state.

kube_pod_init_container_status_last_terminated_timestamp emits the finish time (unix timestamp) of the last termination for an init container that has a LastTerminationState.Terminated record.

Both metrics start at ALPHA and can be graduated once they prove stable, following the standard graduation process.

Changes

  • internal/store/pod.go — added two new generator functions and registered them in createPodFamilyGenerators
  • internal/store/pod_test.go — added two new test cases covering both metrics
  • pkg/app/server_test.go — updated full scrape cycle expected output to include the new HELP/TYPE lines

Testing

make test-unit  # all passing

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 20, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: maksimp13
Once this PR has been reviewed and has the lgtm label, please assign mrueg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 20, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Instrumentation Mar 20, 2026
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 20, 2026
@maksimp13 maksimp13 force-pushed the feature/add-init-container-state-started-last-terminated-metrics branch from b52a67c to 102d158 Compare March 20, 2026 20:15
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Mar 20, 2026
…metrics

Add two new init container metrics equivalent to their regular container counterparts:
- kube_pod_init_container_state_started (STABLE): start time in unix timestamp
  for init containers in Running or Terminated state
- kube_pod_init_container_status_last_terminated_timestamp (ALPHA): last
  terminated time in unix timestamp for init containers
@maksimp13 maksimp13 force-pushed the feature/add-init-container-state-started-last-terminated-metrics branch from 102d158 to ae0e40b Compare March 20, 2026 20:18
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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

Add support for InitContainer create/termination timestamps in Pod Metrics

2 participants