<p>I'm troubleshooting liveness probe failures. I'm able to extract specific entries from k8s event using this approach</p>

<pre><code>k get events --sort-by=.metadata.creationTimestamp | grep Liveness
</code></pre>

<p>I'd like to get only the pod(s) that causing the issue.<br>
I'm considering to pipe a cut, but I'm not sure which delimiter should I use to get the specific column.</p>

<p>Where I can find the delimiter related to that specific k8s resource(Events) used to printout the kubectl output?</p>

<p>Any other suggestion is appreciated</p>

<p>UPDATE
so far these are the best options (w/o using extra tools) satisfying my specific needs:</p>

<pre><code>k get events -o jsonpath='{range .items[*]}{.involvedObject.name}/{.involvedObject.namespace}: {.message}{"\n"}{end}' | grep Liveness

k get events -o custom-columns=POD:.involvedObject.name,NS:.involvedObject.namespace,MGG:.message | grep Liveness
</code></pre>

<p>there is a feature in kubernetes called <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" rel="nofollow noreferrer">jsonpath</a></p>

<p>validate if your jsonpath is correct with this online tool: <a href="https://jsonpath.com/" rel="nofollow noreferrer">https://jsonpath.com/</a></p>

<p>easily go through json keys with this online tool, so you needn't manually type the key names any more): <a href="http://jsonpathfinder.com/" rel="nofollow noreferrer">http://jsonpathfinder.com/</a></p>

<p>so your command will be:</p>

<pre><code>k get events --sort-by=.metadata.creationTimestamp --jsonpath '{ .xxxxxx }' 
</code></pre>

<p><a href="https://i.stack.imgur.com/GYtsY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GYtsY.png" alt="enter image description here"></a>
<a href="https://i.stack.imgur.com/PggIZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PggIZ.png" alt="enter image description here"></a></p>
