how do I tail logs in open shift using oc client
Asked Answered
C

2

14

From the question you can tell I'm a newb.

At the moment to get the logs of my pod I'm doing a ...

oc logs -f api-myapp-v1-48-cdrs2

This shows me everything in the log. How can I tail them instead?

Also I was wodering if someone could point me out to a nice cheat sheet of open shift commands? One that is good for beginners.

thanks

Chimb answered 24/7, 2017 at 4:25 Comment(0)
S
25

Use the --tail option.

oc logs api-myapp-v1-48-cdrs2 --tail=50

You can use the --help option to commands to find out what options they accept.

For some hands on exercises to help you learn OpenShift, see:

Sepulchre answered 24/7, 2017 at 4:35 Comment(11)
Those interactive tutorials are awesome! Exactly what I was looking for. Thank you.Chimb
Keep returning to learn.openshift.com. We will continually be adding more exercises over time.Sepulchre
Is there a way to tail log of all pods of a particular service?Euchromosome
From the command line only by tailing each pod. If your OpenShift installation has aggregated logging installed, then you can use that from the web console to watch logs across whole application.Sepulchre
Hmm, I have running one pod of a my-service. With oc logs -f --tail=50 dc/my-service I have got log of that pod. I will try to spin up multiple pods and see.Euchromosome
Just tested it with 2 pods running. I have got messages only from the fist created pod. :(.Euchromosome
Which is what monitoring logs of dc will do. As I said, you need to run oc logs on each pod. There is really no other way from the command line.Sepulchre
Hmmm :( Can request the feature somewhere ?Euchromosome
The capability is provided by the aggregated logging feature available through the web console. Have you setup aggregated logging for your cluster?Sepulchre
Let us continue this discussion in chat.Euchromosome
There is nothing else I can tell you. Read the documentation is the best thing you can do to learn about it and steps necessary to set it up. docs.openshift.com/container-platform/3.7/install_config/… From the web console, if you do have it, click ob 'View Archive' on top right just above log window for a pod.Sepulchre
C
6

use -f along with tail, that will work

oc logs -f api-myapp-v1-48-cdrs2 --tail=5
Compurgation answered 13/11, 2019 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.