Create a Logstore
Run a CLI command to create a Logstore in a specified project.
Prerequisites
Before you run the CLI command, make sure that the following requirements are met:
SLS is activated. For more information, see Getting started with Simple Log Service.
The SLS CLI is installed and configured. For more information, see Install the CLI and Configure the CLI.
A project is created. For more information, see Create a project.
Command syntax
aliyun sls create-log-store --project=<value> --logstore-name=<value> --ttl=<value> --shard-count=<value> [--auto-split=<value>] [--max-split-shard=<value>] [--mode=<value>] [--hot-ttl=<value>] [--append-meta=<value>] [--enable-tracking=<value>] [--encrypt-conf=<value>]
Parameters
The following table describes the required and command-specific parameters.
Parameter |
Type |
Required |
Example |
Description |
|
String |
Yes |
aliyun-test-project |
The name of the project. A project is the resource management unit in SLS, used for multi-user isolation and access control. |
|
String |
Yes |
aliyun-test-logstore |
The name of the Logstore. The name must be unique within the project and cannot be changed after the Logstore is created. The name can contain only lowercase letters, digits, hyphens (-), and underscores (_). The name must start with a lowercase letter and end with a lowercase letter or digit. The name must be 3 to 63 characters in length. |
|
Integer |
Yes |
30 |
The data retention period. Unit: days. Valid values: 1 to 3650. A value of 3650 indicates permanent retention. |
|
Integer |
Yes |
2 |
The number of shards. Valid values: 1 to 10. |
|
Boolean |
No |
true |
Specifies whether to enable automatic shard splitting. Valid values: true (default) and false. |
|
Integer |
No |
64 |
The maximum number of shards for automatic splitting. Valid values: 1 to 256. This parameter is required when |
|
String |
No |
standard |
The type of the Logstore. SLS provides two types: Standard and Query. Valid values: standard (default), which supports all SLS data analysis features; query, which supports high-performance queries with index traffic costs at approximately half of Standard, but does not support SQL statements. |
|
Integer |
No |
60 |
The retention period of data in the hot storage tier of the Logstore. Unit: days. Minimum value: 7. The value cannot exceed the value of |
|
Boolean |
No |
false |
Specifies whether to record the public IP address of the client. Valid values: true: records the public IP address of the client. false (default): does not record the public IP address of the client. |
|
Boolean |
No |
false |
Specifies whether to enable the web tracking feature. Valid values: true: enables web tracking. false (default): disables web tracking. |
|
String |
No |
N/A |
The encryption configuration. |
Command examples
Create a Logstore
Command example
Create aliyun-test-logstore.
aliyun sls create-log-store --project="aliyun-test-project" --logstore-name="aliyun-test-logstore" --ttl=30 --shard-count=2Response example
If the command succeeds, no response message is returned. You can run the following command to query the details of the Logstore.
aliyun sls get-log-store --project="aliyun-test-project" --logstore="aliyun-test-logstore"The get-log-store request returns the following response:
{
"appendMeta": false,
"archiveSeconds": 0,
"autoSplit": true,
"createTime": 1719280391,
"enable_tracking": false,
"lastModifyTime": 1719282255,
"logstoreName": "demo-logstore",
"maxSplitShard": 64,
"mode": "standard",
"productType": "",
"resourceQuota": {
"storage": {
"preserved": -1,
"used": 0
}
},
"shardCount": 5,
"telemetryType": "",
"ttl": 30
}