All Products
Search
Document Center

Simple Log Service:CreateLogStore

Last Updated:Jun 03, 2026

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.

ActionResource
log:CreateLogStoreacs:log:{#regionId}:{#accountId}:project/{#project}/logstore/{#logstoreName}

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

log:CreateLogStore

create

*LogStore

acs:log:{#regionId}:{#accountId}:project/{#project}/logstore/{#logstoreName}

  • log:TLSVersion
  • log:Encrypted
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:

  • The name must be unique within a project.

  • The name can contain only lowercase letters, digits, hyphens (-), and underscores (_).

  • The name must start and end with a lowercase letter or a digit.

  • The name must be 2 to 63 characters long.

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 enable, encrypt_type, and user_cmk_info parameters. For more information, see EncryptConf.

Example 1 (Enable default encryption):

{
    "enable": true,
    "encrypt_conf": "default"
}

Example 2 (Enable BYOK encryption):

{
    "enable": true,
    "encrypt_conf": "default",
    "user_cmk_info": {
        "cmk_key_id": "xxxxx",
        "arn": "acs:ram::112340000000:role/rolename",
        "region": "cn-hangzhou"
    }
}

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 maxSplitShard.

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 autoSplit to true.

64

appendMeta

boolean

No

Specifies whether to record the source public IP address and the server reception time. Default value: false.

  • true: Log Service automatically appends the public IP address of the source device and the server reception time to the Tag field of logs.

  • false: Log Service does not append the source public IP address or the server reception time.

false

telemetryType

string

No

The type of observable data. Default value: log data. Valid values:

  • None: log data. This is the default value.

  • Metrics: Metrics data.

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 ttl. If you do not specify this parameter, data is stored in the hot storage tier for the entire data retention period specified by ttl.

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:

  • Scenario 1 (Store data in the hot storage tier for 30 days): {"ttl": 30} or {"ttl": 30, "hot_ttl": 30}

  • Scenario 2 (Store data in the hot storage tier for 7 days and in the IA storage tier for 23 days): {"ttl": 30, "hot_ttl": 7}

60

mode

string

No

Log Service provides two types of Logstores: standard and query.

  • standard: Supports end-to-end data analytics. This mode is suitable for scenarios such as real-time monitoring, interactive analysis, and building a complete observability system.

  • query: Supports high-performance queries. The index traffic cost is approximately half that of the standard mode, but SQL analysis is not supported. This mode is suitable for scenarios that involve large volumes of data, long retention periods such as weeks or months, and do not require SQL-based analysis.

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 (ttl) is longer than the sum of the hot storage period (hot_ttl) and the IA storage period (infrequentAccessTTL), the remaining time is the archive storage period.

Examples:

  • Scenario 1 (Store data in the hot storage tier for 7 days and in the IA storage tier for 23 days): {"ttl": 30, "hot_ttl": 7}

  • Scenario 2 (Store data in the hot storage tier for 7 days, in the IA storage tier for 30 days, and in the archive storage tier for 60 days): {"ttl": 97, "hot_ttl": 7, "infrequentAccessTTL": 30}

  • Scenario 3 (Store data in the hot storage tier for 60 days and in the archive storage tier for 60 days, with the IA storage period being 0 days): {"ttl": 120, "hot_ttl": 60, "infrequentAccessTTL": 0}

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.