This document is intended for application owners that run Google Distributed Cloud. This document shows you how to view console logs for virtual machine (VM) that use VM Runtime on GDC. 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 Distributed Cloud.
- The
virtctl
client tool installed as a plugin forkubectl
. 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
:kubectl virt console VM_NAME
Replace
VM_NAME
with 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-get
for Debian-based VMs oryum check-update
for Red Hat-based VMs.Debian-based
apt-get update
Red Hat-based
yum check-update
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 Google Cloud console. VM serial console logs are streamed to Cloud Logging and can be viewed in Logs Explorer. VMs that run using VM Runtime on GDC are classed as containers in the console logs.
In the Google Cloud console, go to the Logs Explorer page in the Logging menu.
In the Query field, enter the following basic query:
resource.type="k8s_container" resource.labels.container_name="log"
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.
What's next
- To learn more about how to filter your console logs, see Build queries in Logs Explorer.