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.
- You need to create a workspace, a project and an account (
project-admin). The account must be invited to the project with the role of
adminat the project level. For more information, see Create Workspaces, Projects, Accounts and Roles.
- You need to enable the KubeSphere Logging System.
Enable Disk Log Collection
Log in to the web console of KubeSphere as
project-adminand go to your project.
From the left navigation bar, select Advanced Settings in Project Settings. Under Disk Log Collection, click to enable the feature.
Create a Deployment
From the left navigation bar, select Workloads in Application Workloads. Under the Deployments tab, click Create.
In the dialog that appears, set a name for the Deployment (for example,
demo-deployment) and click Next.
Under Container Image, click Add Container Image.
alpinein the search bar to use the image (tag:
latest) as an example.
Scroll down to Start Command and select the checkbox. Enter the following values for Run Command and Parameters respectively, click √, and then click Next.
-c,if [ ! -d /data/log ];then mkdir -p /data/log;fi; while true; do date >> /data/log/app-test.log; sleep 30;done
NoteThe command and parameters above mean that the date information will be exported to
/data/logevery 30 seconds.
On the Mount Volumes tab, click to enable Disk Log Collection and click Add Volume.
On the Temporary Volume tab, enter 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.
Click √, and then click Next to continue.
Click Create in Advanced Settings to finish the process.
NoteFor more information, see Deployments.
Under the Deployments tab, click the Deployment just created to go to its detail page.
In Resource Status, you can click to view container details, and then click of
logsidecar-container(filebeat container) to view disk logs.
Alternatively, you can also click in the lower-right corner and select Log Search to view stdout logs. For example, use the Pod name of the Deployment for a fuzzy query: