Using stern together with grep

I’ve been using stern as my goto log viewer for Kubernetes. It supports multiple pods and other convenient functions on top of kubectl logs. And of course, grepping goes hand in hand with log viewing, doesn’t it? To combine grep with stern, I use the following commands:

# For OSX:
# stern <some-prod-prefix> | grep -i --line-buffered -E '<extended-regex>'
$ stern user | grep -i --line-buffered -E 'failed'

# For Linux (Ubuntu specifically):
# stern <some-prod-prefix> | grep -i -E '<extended-regex>'
$ stern user -s 1h | grep -i -E 'error'
---
If you have any questions or feedback, please reach out @flowerinthenyt.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.