View console logs for VMs that use VM Runtime on GDC

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:

Connect to VM

To make sure there are logs to review, connect to your VM and generate some log activity.

  1. 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.

  2. When prompted, enter the user credentials you specified when you created the VM.

  3. Run a command to check for updates, such as apt-get for Debian-based VMs or yum check-update for Red Hat-based VMs.

    Debian-based

     apt-get  
    update 
    

    Red Hat-based

     yum  
    check-update 
    
  4. 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.

  1. In the Google Cloud console, go to the Logs Explorerpage in the Loggingmenu.

    Go to Logs Explorer

  2. In the Queryfield, enter the following basic query:

      resource 
     . 
     type 
     = 
     "k8s_container" 
     resource 
     . 
     labels 
     . 
     container_name 
     = 
     "log" 
     
    
  3. The Query resultswindow shows the output of the console logs from your VMs, as shown in the following example screenshot:

    The output of the query displays the console logs

  4. 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

Design a Mobile Site
View Site in Mobile | Classic
Share by: