Is it possible to tail kubernetes pod logs and grep it?

12/11/2020

Now I am running java in kubernetes pods, now I did not deployment fluentd, I have to tail log in the kubernetes dashbooard UI. But now I want to filter the java log using grep in a simple way like this:

tail -f service.log | grep "simpe info"

Is it possible to do this, in the terminal I just tail the pod's log but I want to tail pod's running service log. Thanks.

-- Dolphin
kubernetes

2 Answers

12/11/2020

You can also try this

kubectl logs -l app=<app-name> | grep "info"
-- Snt
Source: StackOverflow

12/11/2020

You can run kubectl like as shown below

kubectl -n <namespace> exec <pod-name> -- 'tail -f <file-path/file-name> | grep "simpe info"'
-- P Ekambaram
Source: StackOverflow