Use Cloud Shell to manage Simple Log Service resources
Cloud Shell provides a built-in CLI for managing your Simple Log Service resources and data.
Background information
You can manage the following Simple 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
Log on to the Simple Log Service console.
-
In the upper-right corner of the page, click the
icon. -
Follow the on-screen instructions to complete the validation.
-
If you want to persistently store frequently used scripts and files, click Create and Bind in the Mount Storage Space dialog box.
Associate and mount a NAS file system to persistently store your frequently used scripts and files. Otherwise, your files are deleted when the NAS file system is released. Cloud Shell creates a pay-as-you-go Performance NAS file system for you. This may incur a small fee. For more information about billing, see Billing of General-purpose NAS file systems.
NoteWhen you connect to Cloud Shell for the first time, Cloud Shell automatically creates a virtual machine for you. This process can take up to 30 seconds. If you open multiple Cloud Shell windows, all windows connect to the same virtual machine. The number of virtual machines does not increase when you open new command line windows.
After Cloud Shell starts, a command line 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 SLS logs | cloudshell://tutorial/sls-download-log Use Aliyun 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 Simple Log Service resources
The built-in Simple Log Service CLI in Cloud Shell lets you manage log data without additional configuration.
Run CLI subcommands to create projects, manage Logstores, and perform other operations. For more information, see Simple Log Service CLI.
-
Syntax
aliyunlog log <subcommand> [parameters | global options]-
subcommand: The subcommand to run. For more information, see Subcommand list.
-
parameters: The parameters for the subcommand. For more information, see the documentation for each subcommand.
-
global options: The global parameters. For more information, see Global parameters.
Note-
To manage Simple Log Service resources in a region other than the default region, you must specify the target region using the
--region-endpointparameter. -
Cloud Shell is located in the China (Shanghai) region. If your Logstore is not in the China (Shanghai) region, data transfer costs are incurred when you download logs. For more information about pricing, see 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="project-a" --logstore_name="logstore-a" -
Query logs.
aliyunlog log get_log_all --project="project-a" --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
-
(Optional) Step 3: View help
Run the following command to view help for a specific operation:
aliyunlog log [subcommand] help
For example, run the following command to view the syntax of the list_project subcommand.
aliyunlog log list_project help