Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get logs from Kubectl POD specifying Level (only ERROR)

I would like to know if is possible to filter logs, only showing ERROR Level

kubectl logs -f -n the-namespace the-pod [LOG-LEVEL?] in example ERROR only

I was trying with:

kubectl logs -f -n bci-api the-pod | awk '{ if ($3 == "ERROR") { print } }' 

The problem, are there some lines that are continuation of ERROR line and will be hidden!

Is it possible?

Thanks in advance!

like image 933
joseluisbz Avatar asked Sep 12 '25 15:09

joseluisbz


1 Answers

can use grep functionality to filter errors from the entire logs

kubectl logs -f -n bci-api the-pod | grep -i 'Error'
like image 54
Be_hegade Avatar answered Sep 14 '25 12:09

Be_hegade