Collecting debugging information using sosreport

Container-Optimized OS includes the sosreport utility, which collects information on demand to help you debug problems in a Container-Optimized OS virtual machine instance. The information is collected and stored locally on the filesystem of the instance. Google does not collect or store this data elsewhere.

If you open a support case with Google Cloud support due to problems with your instance, you may be asked to provide the sosreport data as part of the investigation. This page shows you how to collect this information.

The output of sosreport is stored without encryption in a .tar.xz archive. The archive may contain personally identifiable information (PII), because it collects data from many critical system components (e.g. journald). The archive can be inspected on the instance, and most content is in plain text. The sosreport tool is open source, and you can review its code.

Collecting the sosreport data

To generate a sosreport:

  1. Connect to the instance using the gcloud compute ssh command.

    gcloud compute ssh [INSTANCE_NAME] --zone [ZONE] --project [PROJECT_ID]
    
  2. Check the OS version:

    sudo cat /etc/os-release| egrep -w 'NAME|VERSION'
    

    The output is similar to the following:

    NAME="Container-Optimized OS"
    VERSION=105
    
  3. Run the sos report command to collect the logs:

    sudo sos report --all-logs --batch --tmp-dir=/var
    

    If the previous command fails with sos: command not found, install the sosreport package and then run the sos report command again:

    sudo toolbox
    sudo apt install sosreport -y
    

    For other supported Linux distributions, including AlmaLinux, Rocky Linux, Oracle Linux, Red Hat Enterprise Linux (RHEL), Ubuntu, and Debian, see Collect diagnostic information from Linux VMs.

You can change the directory where the report is stored by passing a different directory to the --tmp-dir option. You can also change the command's default behavior by editing /etc/sos.conf on the instance.

The output is stored in a .tar.xz file in the directory you specify using the --tmp-dir option. The location and checksum of the .tar.xz file is shown on STDOUT.

Your sosreport has been generated and saved in:
  /var/sosreport-cos-20181106231224.tar.xz

The checksum is: 5a8b97c6020346a688254c8b04ef86ec

Collect networking data on Container-Optimized OS

When you collect a report directly on a Container-Optimized OS host instance, the sos tool doesn't capture networking diagnostic data (such as network interfaces, routing tables, and firewall rules). On Ubuntu nodes, the sos tool collects networking data by default.

To collect networking data on Container-Optimized OS, run sos report inside the toolbox environment:

  1. Start toolbox with root privileges:

    sudo toolbox
    
  2. Install the sosreport package:

    apt-get update && apt-get install -y sosreport
    
  3. Run the sos report command with the --sysroot option and enable the networking plugin:

    sos report --batch \
      --sysroot /media/root \
      --tmp-dir /media/root/var/tmp \
      --plugin-timeout 900 \
      -k crictl.timeout=1800 -k containerd.timeout=1800 \
      -e networking \
      --all-logs
    

    This command uses the following options:

    • --sysroot /media/root: specifies the host root file system mounted inside the toolbox container.
    • --tmp-dir /media/root/var/tmp: specifies that the output archive is saved in the /var/tmp directory on the host.
    • -e networking: enables the networking plugin to capture networking diagnostics.
    • --plugin-timeout 900: sets the plugin timeout to 900 seconds.
    • -k crictl.timeout=1800 -k containerd.timeout=1800: increases timeouts for container runtime queries on busy nodes.
  4. Exit the toolbox environment:

    exit
    

The generated report archive is saved on the host in the /var/tmp/ directory.

Viewing the collected data

The report is owned by root and is not readable by other users. Use the following commands to change the owner to your current user and make it readable by you. Do not make it world-readable.

TARBALL=[PATH/TO/TARBALL]
sudo chown $(whoami) $TARBALL
chmod +r $TARBALL

Then, if you want to view the content of the report on the node, you can extract it by running below command:

tar xvf $TARBALL

The individual report files are now available in a directory in the same location as the .tar.xz. You can view the logs using commands such as less, or you can use commands such as grep to find information in them.

Download the report

To download the report to your local machine, use the gcloud compute scp command:

gcloud compute scp $(whoami)@[INSTANCE_NAME]:[PATH/TO/FILE] [LOCAL/PATH/TO/DIRECTORY]