All Products
Search
Document Center

Simple Log Service:CreateLogStore

Last Updated:Dec 04, 2025

Creates a logstore.

Operation description

  • The Host in the request syntax consists of the project name and the Simple Log Service (SLS) endpoint. You must specify the project in the Host.

  • Create an AccessKey pair. For more information, see AccessKey pair.

An AccessKey pair for an Alibaba Cloud account provides full access to all APIs, which poses a high security risk. We recommend that you create and use a RAM user for API calls and routine O&M. The RAM user must have the permissions required to manage SLS resources. For more information, see Create and authorize a RAM user.

  • Obtain information about the project, such as the project name and the region where the project is located. For more information, see Manage projects.

  • You can create a maximum of 200 logstores in a project.

  • Logs are deleted after their retention period expires.

Authorization

The following table describes the authorization information for this operation. To grant a RAM user or RAM role the permissions to call this operation, add this information to the Action element of a RAM policy.

Action

Resource description in an authorization policy

log:CreateLogStore

acs:log:{#regionId}:{#accountId}:project/{#ProjectName}/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 project name.

ali-test-project

body

object

Yes

The request parameters.

logstoreName

string

Yes

The name of the logstore. The name must meet the following requirements:

  • The name must be unique within a project.

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

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

  • It must be 2 to 63 characters in length.

my-logstore

shardCount

integer

Yes

The number of shards.

Note

You cannot change the number of shards by calling this operation. To change the number of shards, call the SplitShard or MergeShards operation.

2

ttl

integer

Yes

The retention period of data. Unit: days. Valid values: 1 to 3650. If you set this parameter to 3650, the data is permanently stored.

1

encrypt_conf

EncryptConf

No

The data structure of the encryption configuration. The parameters include enable, encrypt_type, and user_cmk_info. For more information, see EncryptConf.

autoSplit

boolean

No

Specifies whether to automatically split shards.

  • true: automatically splits shards.

  • false: does not automatically split shards.

true

enable_tracking

boolean

No

Specifies whether to enable web tracking. The default value is false.

  • true: enables web tracking.

  • false: disables web tracking.

false

maxSplitShard

integer

No

The maximum number of shards that can be generated after an automatic split. The minimum value is 1. The maximum value is 256.

Note

This parameter is required if you set the autoSplit parameter to true.

64

appendMeta

boolean

No

Specifies whether to record the public IP address of the client and the time when SLS receives logs. The default value is false.

  • true: records the public IP address of the client and the time when SLS receives logs. After this feature is enabled, SLS automatically adds the public IP address of the log source device and the server time when the logs are received to the tag field of the logs.

  • false: does not record the public IP address of the client or the time when SLS receives logs.

false

telemetryType

string

No

The type of observable data. Valid values:

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

  • Metrics: metrics.

None

hot_ttl

integer

No

The retention period of data in the hot storage layer of the logstore. Unit: days. The minimum value is 7. The value cannot be greater than the value of ttl. If you set this parameter to -1, data is permanently stored in the hot storage layer.

After the retention period of data in the hot storage layer expires, the data is converted to the IA storage class. For more information, see Enable automatic storage tiering.

60

mode

string

No

SLS provides two types of logstores: Standard and Query.

  • standard: supports one-stop data analytics. This type of Logstore is suitable for scenarios such as real-time monitoring, interactive analysis, and building a complete observability system.

  • query: supports high-performance queries. The cost of index traffic for this type of logstore is about half the cost of a Standard logstore. However, this type of logstore does not support SQL analysis. This type of logstore is suitable for scenarios that involve large amounts of data, long retention periods (weeks or months), and no log analysis requirements.

standard

infrequentAccessTTL

integer

No

The retention period of data in the IA storage class. Data is stored for at least 30 days before it is converted to Archive Storage. The IA storage class does not have a minimum retention period.

30

processorId

string

No

The ID of the ingest processor.

shardingPolicy

ShardingPolicy

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.