Skip to content

Is it possible to retrieve only new logs after recreating LogWatch after closed connection? #5602

Answered by shawkins
if-of asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a way to only retrieve new logs after recreating LogWatch? Currently, when I recreate LogWatch, it restarts log retrieval from the beginning, which can be resource-intensive given the need to re-receive all logs for the past 4 hours.

There are a couple of parameters supported by the log operation - sinceSeconds, and sinceTime. I'm not sure there's a better reference for it, so here's from the kube source https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/logs/logs.go#L176

You can set this prior to the watchLog method:

pod.sinceSeconds("4h").watchLog(out)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by if-of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants