boz / kail

kubernetes log viewer
MIT License
1.98k stars 93 forks source link

Differentiate logs coming from different pods #11

Open kenden opened 7 years ago

kenden commented 7 years ago

It would be nice to differentiate the logs coming from different pods. Show all pods with a different color?

Or maybe, depending on params, something like this:

If logs are shown from different pods, it could be nice to show different colors.
$ kail ---> show all pods in the same namespace with the same colors? Else, different colors?

$ kail --ns kube-system ---> show pods bellonging to the same deployment/daemonset/rs/rc with the same color, and different colors otherwise?

$ kail --ns kube-system --ds <name> $ kail --ns kube-system --deploy <name> $ kail --ns kube-system --rs <name> $ kail --ns kube-system --rc <name> $ kail --ns kube-system --ing <name> ---> show all pods with a different color?

Here is what I miss:

boz commented 7 years ago

I've looked into it a bit. I'm concerned about how easy it is to exhaust all discernibly different colors. After going down a "truecolor" rabbit hole, I put it on the back burner for a while.

Really interesting ideas for reducing the number of colors used. They may make it feasible, but will take a fair amount of code changes.

How does kubetail and stern handle this?

Thanks for the feedback, I'll start thinking this again.

kenden commented 7 years ago

kubetail does it like this, by just getting the next color.

Stern uses https://github.com/fatih/color, here

boz commented 7 years ago

yeah, so stern cycles through six color schemes and kubetail uses ~254 of them and then the behavior seems undefined.

I'm not really satisfied with either approach.

Maybe ~250 colors is enough. Maybe it partitions it by namespace and container (they each use different pools of colors). Whatever happens I think that when pods die they need to relinquish the color that they're using, and something reasonable should happen when there's no more colors available.

An additional problem is that $TERM is not passed through when using docker/kubectl. It's really annoying.

edit: by using background and foreground we can stretch the pallet usage out quite a bit too.

jmreicha commented 6 years ago

Interested in a color option as well. FWIW I would never come close to tailing 250 pods.

boz commented 6 years ago

Thanks for your feedback @jmreicha. Maybe a --no-color or similar switch would be good enough for the large pod count use-cases. I personally don't typically use it with >250 pods.

I'll look at this again when I have some time and/or need a change of pace.

jglick commented 2 years ago

stern seems to do this out of the box (contra https://github.com/wercker/stern/issues/163).