Cloud Shell is integrated with Log Service CLI. Cloud Shell allows you to manage Log Service resources and data by running commands. The commands are in a unified format, which facilitates your management.

Background information

This topic provides examples on how to manage the following Log Service resources:
  • Projects. For example, you can create, query, or delete a project.
  • Logstores. For example, you can create, query, modify, or delete a Logstore.
  • Consumer groups, shards, machine groups, and data shipping tasks. For example, you can create a data shipping task.

Step 1: Start Cloud Shell

  1. Log on to the Log Service console.
  2. In the upper-right corner of the page, click the cloudshell icon.
  3. Follow the on-screen instructions to complete the verification.
  4. If you want to persistently store files and scripts that are commonly used, click Create Now in the Storage Space dialog box.
    You can associate and mount an Apsara File Storage NAS (NAS) file system to persistently store files and scripts that are commonly used. This way, the files are not deleted when the file system is released. Cloud Shell automatically creates a Performance NAS file system that uses the pay-as-you-go billing method. You are charged for the usage of the file system. For more information, see Billing of General-purpose NAS file systems.
    Note When you connect to Cloud Shell for the first time, Cloud Shell automatically creates a VM for you within 30 seconds. If you open multiple Cloud Shell windows, all the windows are connected to the same VM. The number of VMs does not increase when you open a new Cloud Shell window.
    After Cloud Shell is started, a Cloud Shell window appears.
    Welcome to Alibaba Cloud Shell!
    
    Type "help" to learn about Cloud Shell
    Type "aliyun" to use Alibaba Cloud CLI
    
    You may be interested in these tutorials below.
    ---------------------------  |  ---------------------------
    Download logs from Log Service                 |  cloudshell://tutorial/sls-download-log
    Use Alibaba Cloud CLI to manage cloud resources |  cloudshell://tutorial/aliyun-cli
    
    For more tutorials, visit https://api.aliyun.com/#/lab
    shell@Alicloud:~$ 

Step 2: Use CLI commands to manage Log Service resources

Cloud Shell is integrated with Log Service CLI. You can use Cloud Shell to manage log data in Log Service without the need to configure Log Service CLI.

You can use Log Service CLI subcommands to perform various operations. For example, you can create a project or a Logstore. For more information, see Overview of Log Service CLI.
  • Syntax:
    aliyunlog log <subcommand> [parameters | global options]
    • subcommand: the supported subcommand. For more information, see Commands.
    • parameters: the supported parameters. For more information about the parameters that are supported for each subcommand, see the description of each subcommand.
    • global options: the supported global parameters. For more information, see Global variables.
    Note
    • When you manage Log Service resources that belong to a different region from Cloud Shell, you must change the region. You can configure --region-endpoint to specify the region that you want to use.
    • The Cloud Shell server is located 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 transfers over the Internet. For more information, see Log Service pricing.
  • Examples
    • Create a project.
      aliyunlog log create_project --project_name="project-a" --project_des="project created from cli"
    • Create a Logstore.
      aliyunlog log create_logstore --project_name="aliyun-test-project" --logstore_name="logstore-a"
    • Query logs.
      aliyunlog log get_log_all --project="aliyun-test-project" --logstore="logstore-a" --from_time="2021-05-28 15:33:00+8:00" --to_time="2021-05-28 15:40:00+8:00" --query="level:Information|select event_id as Key1,COUNT(*) as Key2 group by Key1" --reverse=true

Step 3: (Optional) Obtain help information

To obtain the help information about a subcommand, use the following syntax:
aliyunlog log [subcommand] help

For example, you can run the following command to view the usage description of the list_project subcommand:

aliyunlog log list_project help

References