This document is intended for application owners that run Anthos clusters on bare metal. This document shows you how to view console logs for virtual machine (VM) that use Anthos VM Runtime. You can use the VM console logs to troubleshoot and diagnose problems in your cluster.
Before you begin
To complete this document, you need access to the following resources:
- A VM that runs in one of your clusters. If needed, create a VM in Anthos clusters on bare metal.
virtctlclient tool installed as a plugin for
kubectl. If needed, install the virtctl client tool.
Connect to VM
To make sure there are logs to review, connect to your VM and generate some log activity.
To access a VM from the console, use
kubectl virt console VM_NAME
VM_NAMEwith the name of the VM that you want to connect to.
When prompted, enter the user credentials you specified when you created the VM.
Run a command to check for updates, such as
apt-getfor Debian-based VMs or
yum check-updatefor Red Hat-based VMs.
After you have successfully generated some console log activity, exit the VM session and console:
Ctrl + ]
View VM console logs
You view VM console logs in the console. VM serial console logs are streamed to Cloud Logging and can be viewed in Logs Explorer. VMs that run using Anthos VM Runtime are classed as containers in the console logs.
In the console, go to the Logs Explorer page in the Logging menu.
In the Query field, enter the following basic query:
The Query results window shows the output of the console logs from your VMs, as shown in the following example screenshot:
You can further filter the results of your query to a particular VM by adding the cluster name and the name of the VM to your query:
resource.type="k8s_container" resource.labels.container_name="log" resource.labels.cluster_name="CLUSTER_NAME" labels.k8s-pod/kubevirt/vm="VM_NAME"
Replace the following:
CLUSTER_NAME: the name of the cluster that contains your VM.
VM_NAME: the name of your VM.
- To learn more about how to filter your console logs, see Build queries in Logs Explorer.