Extract lines from Kubernetes log

11/17/2018

I'm new to kubernetes and am still trying to extract log from a few lines and write it, if anyone can help me what commands i should execute.

If the pod is named bino, and i wanted to extract the lines corresponding to the error unable-to-access-website, and then write them to a certain location, say John/Doe/bino. How would i do this is there a easy command?

I tried using kubectl log bino, but it just dumps all the output on the terminal, if i wanted to write certain parts how can i do it? Thanks!

Or if anyone has played around in katacoda i would appreciate a link to a similar example.

-- Tyler Blake
containers
docker
katacoda
kubernetes

2 Answers

5/24/2019

If you are not that familiar with grep and regular expressions in general, then you can use the Retrospective Log Analyzer https://retrospective.centeractive.com/tutorial_monitorcontainer.html which will do the heavy regex work for you.

It makes extracting certain parts of the logs much easier, you can extract parts from log files and from container logs of Kubernetes and Docker without having to write complex regular expressions.

-- horistack
Source: StackOverflow

11/17/2018

You can use grep in linux to fetch the relevant log messages you want:

kubectl log bino | grep "error unable-to-access-website" >> John/Doe/Bino/log.txt

Hope this helps.

-- Prafull Ladha
Source: StackOverflow