Konsolenlogs für VMs ansehen, die VM Runtime on GDC verwenden
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Dieses Dokument richtet sich an Anwendungsinhaber, die Google Distributed Cloud ausführen.
In diesem Dokument erfahren Sie, wie Sie Konsolenlogs für virtuelle Maschinen (VMs) aufrufen, die VM Runtime on GDC verwenden. Mithilfe der VM-Konsolenlogs können Sie Probleme in Ihrem Cluster beheben und diagnostizieren.
Vorbereitung
Um dieses Dokument abzuschließen, benötigen Sie Zugriff auf die folgenden Ressourcen:
Stellen Sie eine Verbindung zur VM her und generieren Sie Logaktivitäten, um zu prüfen, ob Logs vorhanden sind.
Verwenden Sie kubectl, um über die Konsole auf eine VM zuzugreifen:
kubectlvirtconsoleVM_NAME
Ersetzen Sie VM_NAME durch den Namen der VM, zu der Sie eine Verbindung herstellen möchten.
Wenn Sie dazu aufgefordert werden, geben Sie die Nutzeranmeldedaten ein, die Sie beim Erstellen der VM angegeben haben.
Führen Sie einen Befehl aus, um nach Updates zu suchen, z. B. apt-get für Debian-basierte VMs oder yum check-update für Red Hat-basierte VMs.
Debian-basiert
apt-getupdate
Red Hat-basiert
yumcheck-update
Nachdem Sie einige Konsolen-Logaktivitäten generiert haben, beenden Sie die VM-Sitzung und -Konsole:
Ctrl+]
Logs der VM-Konsole ansehen
Sie rufen VM-Konsolenlogs in der Google Cloud Console auf. Logs von seriellen Konsolen-VMs werden an Cloud Logging gestreamt und können im Log-Explorer aufgerufen werden. VMs, die mit VM Runtime on GDC ausgeführt werden, werden in den Konsolenlogs als Container klassifiziert.
Rufen Sie in der Google Cloud Console im Menü Logging die Seite Log-Explorer auf.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-04-30 (UTC)."],[],[],null,["This 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\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 Google Distributed Cloud](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart).\n- The `virtctl` client tool installed as a plugin for `kubectl`. If needed, [install the virtctl client tool](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/quickstart#install_the_virtctl_client_tool).\n\nConnect to VM\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\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- To learn more about how to filter your console logs, see [Build queries in Logs Explorer](/logging/docs/view/building-queries)."]]