<p>Using this command, I am able to get the container name that have restarted.</p>
<p><code>kubectl get pods -o jsonpath='{.items[*].status.containerStatuses[?(@.restartCount&gt;0)].name}'</code></p>
<p>Is there a way to get the pod name as well in the same command?</p>

Anshul Prakash
<p>It's much easier to get json with kubectl and then process it with jq :</p>
<pre><code>#!/usr/bin/env bash

kubectl get pods -o=json |
    jq -r '.items[] |
        &quot;\(.metadata.name) \(.status.containerStatuses[]|select(.restartCount&gt;0).name)&quot;'
</code></pre>
