|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/logging_events_monitoring/virt-logs.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="virt-viewing-logs-cli_{context}"] |
| 7 | += Viewing {VirtProductName} logs with the CLI |
| 8 | + |
| 9 | +Configure log verbosity for {VirtProductName} components by editing the `HyperConverged` custom resource (CR). Then, view logs for the component pods by using the `oc` CLI tool. |
| 10 | + |
| 11 | +.Procedure |
| 12 | + |
| 13 | +. To set log verbosity for specific components, open the `HyperConverged` CR in your default text editor by running the following command: |
| 14 | ++ |
| 15 | +[source,terminal] |
| 16 | +---- |
| 17 | +$ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv |
| 18 | +---- |
| 19 | + |
| 20 | +. Set the log level for one or more components by editing the `spec.logVerbosityConfig` stanza. For example: |
| 21 | ++ |
| 22 | +[source,yaml] |
| 23 | +---- |
| 24 | +apiVersion: hco.kubevirt.io/v1beta1 |
| 25 | +kind: HyperConverged |
| 26 | +metadata: |
| 27 | + name: kubevirt-hyperconverged |
| 28 | +spec: |
| 29 | + logVerbosityConfig: |
| 30 | + kubevirt: |
| 31 | + virtAPI: 5 <1> |
| 32 | + virtController: 4 |
| 33 | + virtHandler: 3 |
| 34 | + virtLauncher: 2 |
| 35 | + virtOperator: 6 |
| 36 | +---- |
| 37 | +<1> The log verbosity value must be an integer in the range `1–9`, where a higher number indicates a more detailed log. In this example, the `virtAPI` component logs are exposed if their priority level is `5` or higher. |
| 38 | + |
| 39 | +. Apply your changes by saving and exiting the editor. |
| 40 | + |
| 41 | +. View a list of pods in the {VirtProductName} namespace by running the following command: |
| 42 | ++ |
| 43 | +[source,terminal] |
| 44 | +---- |
| 45 | +$ oc get pods -n openshift-cnv |
| 46 | +---- |
| 47 | ++ |
| 48 | +.Example output |
| 49 | +[%collapsible] |
| 50 | +==== |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +NAME READY STATUS RESTARTS AGE |
| 54 | +disks-images-provider-7gqbc 1/1 Running 0 32m |
| 55 | +disks-images-provider-vg4kx 1/1 Running 0 32m |
| 56 | +virt-api-57fcc4497b-7qfmc 1/1 Running 0 31m |
| 57 | +virt-api-57fcc4497b-tx9nc 1/1 Running 0 31m |
| 58 | +virt-controller-76c784655f-7fp6m 1/1 Running 0 30m |
| 59 | +virt-controller-76c784655f-f4pbd 1/1 Running 0 30m |
| 60 | +virt-handler-2m86x 1/1 Running 0 30m |
| 61 | +virt-handler-9qs6z 1/1 Running 0 30m |
| 62 | +virt-operator-7ccfdbf65f-q5snk 1/1 Running 0 32m |
| 63 | +virt-operator-7ccfdbf65f-vllz8 1/1 Running 0 32m |
| 64 | +---- |
| 65 | +==== |
| 66 | +
|
| 67 | +. To view logs for a component pod, run the following command: |
| 68 | ++ |
| 69 | +[source,terminal] |
| 70 | +---- |
| 71 | +$ oc logs -n openshift-cnv <pod_name> |
| 72 | +---- |
| 73 | ++ |
| 74 | +For example: |
| 75 | ++ |
| 76 | +[source,terminal] |
| 77 | +---- |
| 78 | +$ oc logs -n openshift-cnv virt-handler-2m86x |
| 79 | +---- |
| 80 | ++ |
| 81 | +[NOTE] |
| 82 | +==== |
| 83 | +If a pod fails to start, you can use the `--previous` option to view logs from the last attempt. |
| 84 | + |
| 85 | +To monitor log output in real time, use the `-f` option. |
| 86 | +==== |
| 87 | ++ |
| 88 | +.Example output |
| 89 | +[%collapsible] |
| 90 | +==== |
| 91 | +[source,terminal] |
| 92 | +---- |
| 93 | +{"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373695Z"} |
| 94 | +{"component":"virt-handler","level":"info","msg":"set verbosity to 2","pos":"virt-handler.go:453","timestamp":"2022-04-17T08:58:37.373726Z"} |
| 95 | +{"component":"virt-handler","level":"info","msg":"setting rate limiter to 5 QPS and 10 Burst","pos":"virt-handler.go:462","timestamp":"2022-04-17T08:58:37.373782Z"} |
| 96 | +{"component":"virt-handler","level":"info","msg":"CPU features of a minimum baseline CPU model: map[apic:true clflush:true cmov:true cx16:true cx8:true de:true fpu:true fxsr:true lahf_lm:true lm:true mca:true mce:true mmx:true msr:true mtrr:true nx:true pae:true pat:true pge:true pni:true pse:true pse36:true sep:true sse:true sse2:true sse4.1:true ssse3:true syscall:true tsc:true]","pos":"cpu_plugin.go:96","timestamp":"2022-04-17T08:58:37.390221Z"} |
| 97 | +{"component":"virt-handler","level":"warning","msg":"host model mode is expected to contain only one model","pos":"cpu_plugin.go:103","timestamp":"2022-04-17T08:58:37.390263Z"} |
| 98 | +{"component":"virt-handler","level":"info","msg":"node-labeller is running","pos":"node_labeller.go:94","timestamp":"2022-04-17T08:58:37.391011Z"} |
| 99 | +---- |
| 100 | +==== |
0 commit comments