Collect diagnostic archives from Compute Engine Linux virtual machine (VM)
instances to help Cloud Customer Care investigate
operating system (OS) issues. Use the sosreport tool on most Linux
distributions, or use the supportconfig tool on SUSE Linux.
For Container-Optimized OS VMs, see Collecting debugging information using sosreport. For Windows Server VMs, see Collecting diagnostic information.
Before you begin
-
Make sure that you have
sudoprivileges on the Linux VM and can connect to it by using SSH. For more information, see Connect to Linux VMs. -
If you haven't already, set up authentication.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
Why Customer Care needs diagnostic information
When Customer Care troubleshoots complex VM issues, engineers often need to inspect the internal state of the guest OS. Common examples include performance bottlenecks, networking problems, OS registration failures, and errors during package installation or system updates.
To identify the root cause of these issues, support engineers analyze system logs and configuration files from the VM. A single log or configuration file rarely provides enough context to resolve the issue, so engineers need a comprehensive set of system files.
About the sosreport tool
The sosreport tool, also known as sos, is an open-source, extensible
utility for collecting support data on Linux distributions and other Unix-like
operating systems. You can view the source code and learn more in the
sosreport GitHub repository.
Technical support teams use sosreport to automatically gather logs and system
information for troubleshooting OS issues. Instead of requiring you to manually
run dozens of commands and copy log files individually, sosreport creates a
standardized, compressed archive containing this data.
The tool uses plugins to run system commands and collect relevant files to capture the state of the machine. Examples of collected information include the following:
- Running processes: the state of active tasks on the system from commands
such as
ps,pstree, andlsof. - Resource usage: memory usage from the
freecommand, disk space from commands such asdf, and system load fromuptime. - Configuration files for the OS and services: system and service
configuration files, including the contents of directories such as
/etcthat store local service configurations. - Hardware and kernel details: hardware diagnostics, the running kernel version, and loaded kernel modules.
- Installed software: a list of installed packages from the package
manager, such as the output of
dpkg -lorrpm -qa.
Install the sosreport tool
The package name and installation command depend on the Linux distribution on your VM. After you connect to your VM, select one of the following options:
AlmaLinux, Rocky Linux, Oracle Linux
-
Check whether the
sospackage is installed:dnf list installed sos
-
If the package isn't installed, install
sos:sudo dnf install -y sos
Red Hat Enterprise Linux (RHEL)
-
Check whether the
sospackage is installed:dnf list installed "*sos*"
-
If the package isn't installed, install
sosand its required packages:sudo dnf install -y sos python3-packaging python3-setuptools
Ubuntu 26.04+, Debian 13+
On Ubuntu 26.04 LTS and later, or Debian 13 and later, complete the following steps:
-
Check whether the
sospackage is installed:apt list --installed sos
-
If the package isn't installed, install
sos:sudo apt install sos
Ubuntu 18.04-24.04, Debian 12
On Ubuntu 18.04 LTS to 24.04 LTS, or Debian 12, complete the following steps:
-
Check whether the
sosreportpackage is installed:apt list --installed sosreport
-
If the package isn't installed, install
sosreport:sudo apt install sosreport
For Container-Optimized OS, see Collecting debugging information using sosreport. For SUSE Linux, skip this section and see Collect diagnostic information on SUSE Linux.
Generate a sosreport archive
Complete the following steps on AlmaLinux, Debian, Oracle Linux, RHEL, Rocky Linux, and Ubuntu VMs. For Container-Optimized OS, see Collecting the sosreport data.
Optional: Estimate the disk space required for the archive:
sudo sos report --batch --alloptions --all-logs --estimate-onlyThe
--estimate-onlyflag was introduced in sos 4.3 on GitHub and isn't available in earlier versions, such as the version on Debian 12.Verify that the target partition has enough free disk space. By default,
sosreportsaves the archive in/var/tmp/on most distributions, except on Debian and Ubuntu 24.04 LTS and earlier, where it uses/tmp/. If free space is limited, use the--tmp-dirflag to write the archive to a partition with more free space.Generate the diagnostic archive:
sudo sos report --batch --alloptions --all-logsWhen the command finishes,
sosreportprints the path to the generated compressed archive, which has a filename similar tososreport-hostname-YYYY-MM-DD-abcdef.tar.xz.To avoid permission errors when you retrieve the archive, make your user the owner of the archive:
sudo chown "$(whoami)" SOSREPORT_FILE_PATHReplace
SOSREPORT_FILE_PATHwith the full path to the generatedsosreportarchive.
Common sosreport flags
The following table describes commonly used sos report flags:
| Flag | Description |
|---|---|
--alloptions |
Enables all options for loaded plugins. |
--all-logs |
Collects all available logs regardless of size. |
--batch |
Runs in batch mode without interactive prompts. |
--clean |
Obfuscates sensitive information in the archive. |
--estimate-only |
Estimates required disk space for a full sos run. |
--tmp-dir |
Specifies an alternate temporary directory. |
To view all available flags, check the command help:
sos report --help
Collect diagnostic information on SUSE Linux
On SUSE Linux VMs, use the supportconfig tool from the supportutils package
to collect diagnostic information. After you connect to your SUSE Linux VM,
complete the following steps:
Check whether
supportconfigis installed:sudo supportconfig -hThe
supportconfigtool is usually preinstalled on SUSE Linux VMs. If it isn't installed, install thesupportutilspackage:sudo zypper install -y supportutilsGenerate a system overview report:
sudo supportconfig -lThe
-lflag gathers additional rotated logs.The
supportconfigtool collects system information, creates a compressed archive, and prints the path to the generated file. By default,supportconfigsaves the archive in/var/log/with a filename in the formatscc_HOSTNAME_DATE_TIME.txz, whereHOSTNAMEis the VM hostname,DATEis the collection date, andTIMEis the collection time.To avoid permission errors when you retrieve the archive, make your user the owner of the archive:
sudo chown "$(whoami)" SUPPORTCONFIG_FILE_PATHReplace
SUPPORTCONFIG_FILE_PATHwith the full path to the generatedsupportconfigarchive.
Retrieve the diagnostic archive from the VM
After you generate the diagnostic archive on the VM, download it to your local machine. Select one of the following options:
Console
In the Google Cloud console, go to the VM instances page:
In the list of VMs, click SSH in the row of the VM that contains the diagnostic archive.
On the SSH-in-browser toolbar, click DOWNLOAD FILE.
For Path, in the Absolute file path field, enter the full path to the diagnostic archive on the VM.
Click Download.
The archive downloads to the default download folder on your workstation. For more information, see Transfer files using SSH-in-browser.
gcloud
If you have the Google Cloud CLI installed locally, copy the archive to your
local machine by using the
gcloud compute scp command:
gcloud compute scp USERNAME@INSTANCE_NAME:REMOTE_FILE_PATH \
LOCAL_DESTINATION_PATH \
--zone=ZONE \
--project=PROJECT_ID \
--compress
Replace the following:
USERNAME: the username on the VM that owns the diagnostic archive.INSTANCE_NAME: the name of the VM.REMOTE_FILE_PATH: the full path to the diagnostic archive on the VM.LOCAL_DESTINATION_PATH: the destination directory on your local machine.ZONE: the zone of the VM.PROJECT_ID: the ID of the Google Cloud project.
Optional: After you retrieve the diagnostic archive, review it for confidential or personally identifiable information (PII) and mask or remove any sensitive data before uploading it.
When the archive is ready, attach it to your Customer Care support case. For more information about uploading attachments to an open case, see Update a support case.
What's next
- Learn how to
collect debugging information on Container-Optimized OS by using
the
sosreporttool. - Learn how to collect diagnostic information from Windows Server VMs.
- Learn how to create and manage support cases.