Version 1.16. This version is no longer supported. For information about how to upgrade to version 1.28, seeUpgrade clustersin the latest documentation. For more information about supported and unsupported versions, see theVersioningpage in the latest documentation.
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:
To make sure there are logs to review, connect to your VM and generate some log
activity.
To access a VM from the console, usekubectl:
kubectlvirtconsoleVM_NAME
ReplaceVM_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 asapt-getfor Debian-based VMs
oryum check-updatefor Red Hat-based VMs.
Debian-based
apt-getupdate
Red Hat-based
yumcheck-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 theLogs Explorerpage in theLoggingmenu.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis guide demonstrates how to access and view console logs for virtual machines (VMs) running on Google Distributed Cloud (GDC) using VM Runtime.\u003c/p\u003e\n"],["\u003cp\u003eTo begin, you will need a running VM and the \u003ccode\u003evirtctl\u003c/code\u003e client tool installed as a \u003ccode\u003ekubectl\u003c/code\u003e plugin, both accessible in your cluster.\u003c/p\u003e\n"],["\u003cp\u003eConnect to your VM via \u003ccode\u003ekubectl virt console\u003c/code\u003e to generate log activity by running commands like \u003ccode\u003eapt-get update\u003c/code\u003e or \u003ccode\u003eyum check-update\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eVM console logs are streamed to Cloud Logging, accessible through the Logs Explorer, where they can be viewed by querying for \u003ccode\u003ek8s_container\u003c/code\u003e resources with the container name "log".\u003c/p\u003e\n"],["\u003cp\u003eYou can filter your logs to view results from a specific VM by adding the cluster name and VM name to the query in Logs Explorer.\u003c/p\u003e\n"]]],[],null,["# View console logs for VMs that use VM Runtime on GDC\n\n\u003cbr /\u003e\n\nThis document is intended for application owners that run Google Distributed Cloud.\nThis document shows you how to view console logs for virtual machine (VM) that\nuse VM Runtime on GDC. You can use the VM console logs to\ntroubleshoot and diagnose problems in your cluster.\n\nBefore you begin\n----------------\n\nTo complete this document, you need access to the following resources:\n\n- A VM that runs in one of your clusters. If needed, [create a VM in Distributed Cloud](/anthos/clusters/docs/bare-metal/1.16/vm-runtime/quickstart).\n- The `virtctl` client tool installed as a plugin for `kubectl`. If needed, [install the virtctl client tool](/anthos/clusters/docs/bare-metal/1.16/vm-runtime/quickstart#install_the_virtctl_client_tool).\n\nConnect to VM\n-------------\n\nTo make sure there are logs to review, connect to your VM and generate some log\nactivity.\n\n1. To access a VM from the console, use `kubectl`:\n\n kubectl virt console \u003cvar label=\"name\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM that you want to\n connect to.\n2. When prompted, enter the user credentials you specified when you created the\n VM.\n\n3. Run a command to check for updates, such as `apt-get` for Debian-based VMs\n or `yum check-update` for Red Hat-based VMs.\n\n ### Debian-based\n\n apt-get update\n\n ### Red Hat-based\n\n yum check-update\n\n4. After you have successfully generated some console log activity, exit the VM\n session and console:\n\n Ctrl + ]\n\nView VM console logs\n--------------------\n\nYou view VM console logs in the Google Cloud console. VM serial console logs\nare streamed to Cloud Logging and can be viewed in Logs Explorer. VMs\nthat run using VM Runtime on GDC are classed as containers in the\nconsole logs.\n\n1. In the Google Cloud console, go to the **Logs Explorer** page in the\n **Logging** menu.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs/query)\n2. In the **Query** field, enter the following basic query:\n\n resource.type=\"k8s_container\"\n resource.labels.container_name=\"log\"\n\n3. The **Query results** window shows the output of the console logs from\n your VMs, as shown in the following example screenshot:\n\n4. You can further filter the results of your query to a particular VM by adding\n the cluster name and the name of the VM to your query:\n\n resource.type=\"k8s_container\"\n resource.labels.container_name=\"log\"\n resource.labels.cluster_name=\"\u003cvar label=\"name of your cluster containing the VM\" translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n labels.k8s-pod/kubevirt/vm=\"\u003cvar label=\"name of your VM\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e\"\n\n Replace the following:\n - \u003cvar scope=\"CLUSTER_NAME\" translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the cluster that contains your VM.\n - \u003cvar scope=\"VM_NAME\" translate=\"no\"\u003eVM_NAME\u003c/var\u003e: the name of your VM.\n\nWhat's next\n-----------\n\n- To learn more about how to filter your console logs, see [Build queries in Logs Explorer](/logging/docs/view/building-queries)."]]