You are viewing documentation for KubeSphere version:v3.0.0

KubeSphere v3.0.0 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date documentation, see the latest version.

Disk Log Collection

KubeSphere supports multiple log collection methods so that Ops teams can collect, manage and analyze logs in a unified and flexible way.

This tutorial demonstrates how to collect disk logs for an example app.

Prerequisites

Enable Disk Log Collection

  1. Log in to the web console of KubeSphere as project-admin and go to your project.

  2. From the left navigation bar, select Advanced Settings in Project Settings. Under Disk Log Collection, enable the feature through the toggle switch.

    enable-disk-log-collection

Create a Deployment

  1. From the left navigation bar, select Workloads in Application Workloads. Under the Deployments tab, click Create.

  2. In the dialog that appears, set a name for the Deployment (for example, demo-deployment) and click Next.

  3. Under Container Image, click Add Container Image.

  4. Enter alpine in the search bar to use the image (tag: latest) as an example.

    alpine-image

  5. Scroll down to Start Command and check it. Input the following values for Run Command and Parameters respectively, click , and then click Next.

    Run Command

    /bin/sh
    

    Parameters

    -c,if [ ! -d /data/log ];then mkdir -p /data/log;fi; while true; do date >> /data/log/app-test.log; sleep 30;done
    

    Note

    The command and parameters above mean that the date information will be exported to app-test.log in /data/log every 30 seconds.

    run-command

  6. On the Mount Volumes tab, enable Disk Log Collection and click Add Volume.

    mount-volumes

  7. On the Temporary Volume tab, input a name for the volume (for example, demo-disk-log-collection) and set the access mode and path. Refer to the image below as an example.

    volume-example

    Click , and then click Next to continue.

  8. Click Create in Advanced Settings to finish the process.

    Note

    For more information, see Deployments.

View Logs

  1. Under the Deployments tab, click the Deployment just created to go to its detail page.

  2. In Resource Status, click the arrow on the right to view container details, and then click the log icon of logsidecar-container (filebeat container) to inspect disk logs.

    container-log

    inspect-logs

  3. Alternatively, you can also use the Log Search function from Toolbox in the bottom right corner to view stdout logs. For example, use the Pod name of the Deployment for a fuzzy query:

    fuzzy-match