All Products
Search
Document Center

Simple Log Service:Use Cloud Shell to download logs from Simple Log Service

Last Updated:Oct 26, 2023

You can use Cloud Shell to download a large number of log files from Simple Log Service and upload the files to Object Storage Service (OSS) within a short period of time. This topic describes how to use Cloud Shell to download logs.

Prerequisites

If you use a RAM user to download logs, you must grant the following permissions to the RAM user:

Procedure

  1. Log on to the Log Service console.

  2. In the Projects section, click the project that you want to manage.

  3. On the Log Storage > Logstores tab, click the Logstore that you want to manage.

  4. In the search box, enter a query statement. Then, select a time range and click Search & Analyze.

  5. On the Raw Logs tab, click the download icon and select Download Log.

  6. In the Log Download dialog box, click Download with Cloud Shell and click OK.

    If the log file is for temporary use, you do not need to associate or mount an Apsara File Storage NAS (NAS) file system to store the log file. Select Not Create.

    Note

    The Cloud Shell server resides in the China (Shanghai) region. If you download logs from a Logstore that does not reside in the China (Shanghai) region, you are charged for data transfer over the Internet. For more information, see Simple Log Service pricing.

  7. In the Download File dialog box of the Cloud Shell window, click OK.

    A TXT-formatted file is downloaded to your computer.

  8. If you want to upload the downloaded log file to an OSS bucket, perform the following operations:

    1. Run the following command to view the OSS buckets that you can manage. This way, you can determine the OSS bucket in which you can store the log file.

      aliyun oss ls

      If the command is successfully run, the system returns a list of OSS buckets that you can manage.

      CreationTime                                 Region    StorageClass    BucketName
      2021-09-24 02:03:08 +0000 UTC        oss-cn-beijing        Standard    oss://fyytset
      2021-09-26 03:27:10 +0000 UTC       oss-cn-hangzhou        Standard    oss://demo
      Bucket Number is: 2
    2. Run the cd aliyunlog command to go to the aliyunlog directory and run the ll command to find the downloaded log file.

      The downloaded log file is named in the data_202***_100331.txt format.

      total 8640
      drwxr-xr-x 2 shell shell    4096 Sep 28 10:21 ./
      drwxr-xr-x 6 shell shell    4096 Sep 28 10:24 ../
      -rw-r--r-- 1 shell shell 3198090 Sep 28 10:03 data_20210928_100331.txt 
    3. Run the following command to upload the log file to the OSS bucket:

      aliyun oss cp data_20210928_100331.txt oss://demo --region cn-hangzhou

      If the following information is returned, the log file is uploaded:

      Succeed: Total num: 1, size: 3,198,090. OK num: 1(upload 1 files).
      
      average speed 12792000(byte/s)
      
      0.250823(s) elapsed