Skip to content

Conversation

@MichaelKatsoulis
Copy link
Contributor

Proposed commit message

  • WHAT: populate field status.last_terminated_exitcode in kubernetes.state_container metricset
  • WHY: track container termination reasons more accurately

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None

How to test this PR locally

  1. Create a GKE kubernetes cluster
  2. Install kube-state-metrics (tested will all supported versions)
  3. Run metricbeat in k8s pod with all state-* metricsets configured. https://github.com/elastic/beats/blob/main/metricbeat/module/kubernetes/_meta/test/docs/README.md
  4. Create a pod that crashes with a status code. For example
apiVersion: v1
kind: Pod
metadata:
  name: failpodloop
  namespace: default
spec:
  restartPolicy: Always
  containers:
  - name: fail
    image: busybox
    command: ['sh', '-c', 'sleep 2 && exit 42']  # Runs, exits with 42, then restarts
  1. Check Kibana discovery for fields present in kubernetes.state_container metricset.

Related issues

@MichaelKatsoulis MichaelKatsoulis requested review from a team as code owners December 8, 2025 11:05
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented Dec 8, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @MichaelKatsoulis? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@MichaelKatsoulis MichaelKatsoulis added backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team labels Dec 10, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 10, 2025
@MichaelKatsoulis MichaelKatsoulis enabled auto-merge (squash) December 10, 2025 09:59
Copy link
Contributor

@theletterf theletterf left a comment

Choose a reason for hiding this comment

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

LGTM.

@MichaelKatsoulis MichaelKatsoulis merged commit 71fb391 into elastic:main Dec 11, 2025
54 checks passed
@github-actions
Copy link
Contributor

@Mergifyio backport 9.1 9.2

@mergify
Copy link
Contributor

mergify bot commented Dec 11, 2025

backport 9.1 9.2

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Dec 11, 2025
#47968)

* Add status.last_terminated_exitcode field in state_container metricset

* Update metricbeat/module/kubernetes/state_container/_meta/fields.yml

Co-authored-by: Andrew Gizas <[email protected]>

* Add changelog and update documentation example

* Update changelog/fragments/1765359658-k8s_status_last_terminated_exitcode.yaml

Co-authored-by: Andrew Gizas <[email protected]>

---------

Co-authored-by: Andrew Gizas <[email protected]>
(cherry picked from commit 71fb391)
mergify bot pushed a commit that referenced this pull request Dec 11, 2025
#47968)

* Add status.last_terminated_exitcode field in state_container metricset

* Update metricbeat/module/kubernetes/state_container/_meta/fields.yml

Co-authored-by: Andrew Gizas <[email protected]>

* Add changelog and update documentation example

* Update changelog/fragments/1765359658-k8s_status_last_terminated_exitcode.yaml

Co-authored-by: Andrew Gizas <[email protected]>

---------

Co-authored-by: Andrew Gizas <[email protected]>
(cherry picked from commit 71fb391)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches Team:Cloudnative-Monitoring Label for the Cloud Native Monitoring team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Kubernetes module] Populate kube_pod_container_status_last_terminated_exitcode

3 participants