Skip to content

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

Open
jihuichoi wants to merge 3 commits intojohanhaleby:masterfrom
jihuichoi:master
Open

add new feature, sed, Manipulate lines using sed#79
jihuichoi wants to merge 3 commits intojohanhaleby:masterfrom
jihuichoi:master

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.

2 participants