Creates a Logstore.
Operation description
Usage notes
The Host header of the request consists of a project name and a Log Service endpoint. You must specify the project in this header.
You must create and obtain an AccessKey. For more information, see AccessKey.
An Alibaba Cloud account's AccessKey pair has full permissions for all API operations, which poses a security risk. For enhanced security, we strongly recommend using a RAM user to call API operations or perform routine O&M. You must grant the RAM user permissions to manage Log Service resources. For more information, see Create and authorize a RAM user.
-
Ensure you have the name and region of the project where you want to create the Logstore. For more information, see Manage projects.
-
You can create a maximum of 200 Logstores in a project.
-
Log Service automatically deletes logs after the specified data retention period expires.
Authorization
The following table lists the permission required to call this API. To grant this permission to a RAM user or RAM role, add the corresponding Action to a RAM policy statement.
| Action | Resource |
log:CreateLogStore | acs:log:{#regionId}:{#accountId}:project/{#project}/logstore/{#logstoreName} |
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
log:CreateLogStore |
create |
*LogStore
|
|
None |
Request syntax
POST /logstores HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| project |
string |
Yes |
The name of the project. |
ali-test-project |
| body |
object |
Yes |
The request body parameters. |
|
| logstoreName |
string |
Yes |
The name of the Logstore. The name must meet the following requirements:
|
my-logstore |
| shardCount |
integer |
Yes |
The number of shards. Note
You cannot update the shard count with this operation. To do so, call the SplitShard or MergeShards operation. |
2 |
| ttl |
integer |
Yes |
The data retention period in days. Valid values: 1 to 3,650. If you set this parameter to 3,650, data is stored permanently. |
1 |
| encrypt_conf | EncryptConf |
No |
The encryption configuration. This data structure includes the Example 1 (Enable default encryption):
Example 2 (Enable BYOK encryption): |
|
| autoSplit |
boolean |
No |
Specifies whether to enable automatic shard splitting. If you set this parameter to true, Log Service automatically splits a shard to increase write throughput when the write traffic to the shard continuously exceeds the service limit. If you enable automatic shard splitting, you must also specify |
true |
| enable_tracking |
boolean |
No |
Specifies whether to enable WebTracking. The default value is false. This feature lets you collect and analyze user behavior data from browsers or mini programs, such as page views, purchase history, and dwell time. |
false |
| maxSplitShard |
integer |
No |
The maximum number of shards after an automatic split. The value must be an integer from 1 to 256. Note
This parameter is required if you set |
64 |
| appendMeta |
boolean |
No |
Specifies whether to record the source public IP address and the server reception time. Default value: false.
|
false |
| telemetryType |
string |
No |
The type of observable data. Default value: log data. Valid values:
|
None |
| hot_ttl |
integer |
No |
The retention period of data in the hot storage tier of the Logstore, in days. The value must be an integer from 7 to the value of After the hot storage retention period expires, data is moved to the Infrequent Access (IA) storage tier. To enable IA storage, you must set the hot storage retention period to at least 7 days. For more information, see Smart Tiered Storage. Examples:
|
60 |
| mode |
string |
No |
Log Service provides two types of Logstores: standard and query.
|
standard |
| infrequentAccessTTL |
integer |
No |
The retention period for Infrequent Access (IA) storage, in days. While this parameter has no minimum value, data must remain in the IA storage tier for at least 30 days before it can be moved to archive storage. If the total retention period ( Examples:
|
30 |
| processorId |
string |
No |
The ID of the IngestProcessor. |
processor-nginx-parser-001 |
| shardingPolicy | ShardingPolicy |
No |
The configuration for hash-based writes. When you write data, logs are stored in a shard that is selected based on the configured hash-based sharding policy. Before you configure this parameter, make sure that the hash ranges of the shards are evenly distributed. Improper configuration may affect write performance. Configure this parameter with caution. |
|
| resourceGroupId |
string |
No |
The ID of the resource group to which the Logstore belongs. |
rg-xxxxxxxx |
| enableModify |
boolean |
No |
Response elements
|
Element |
Type |
Description |
Example |
None defined.
Examples
Success response
JSON format
{}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.