Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feature, sed, Manipulate lines using sed #79

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jihuichoi
Copy link

@jihuichoi jihuichoi commented Feb 1, 2019

It's a simple feature. Probably self-explanatory.
I can change the log format but sometimes just want to see in shortform or give some alarm on it for temporary. I guess this feature will be good for that sort of demands.

usage:
$ kubetail -sed 's/findString/replaceString/g'

or
$ kubetail -sed 's/findString/replaceString/g' -sed 's/findString2/replaceString2/g'

@johanhaleby
Copy link
Owner

Thanks for the PR! Before I merge this in, isn't it possible to pipe the stream to sed instead of adding it to the bash script?

@jihuichoi
Copy link
Author

jihuichoi commented Feb 6, 2019

isn't it possible to pipe the stream to sed instead of adding it to the bash script?

Yes. it's possible. However it was extremely slow.
At the first time, I tried simply like this.

kubetail my-deploy | sed 's/foo/bar/g'

it worked, but it was too slow.
In my case, my deploy has 5 pods and each pods write logs for every second.
above pipe method worked well for few minutes but after that, it got slower and slower.

Secondly, I tried another way like grep code in existing kubetail code.

line_buffered="| grep - --line-buffered"
sed="| sed -e 's/foo/bar/g'"

I don't know why but anyway it didn't work. it seemed to treat additional "sed" command as tail's option.

I'm not an expert of shellscript, so my method might not be the best way. but it works very well for me and it is my best code.(a little bit ugly, though) I wish you or another folks make it pretty if you think it's useful. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants