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
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
- Create a project.
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