CreateLogStore

Updated at:

Creates a Logstore.

Operation description

Operation description

  • The host in the request syntax consists of the project name and the Simple Log Service endpoint. You must specify the project in the host. For more information about the format, see API request host description.

  • Create and obtain an AccessKey pair. For more information, see AccessKey pairs.

    The AccessKey pair of an Alibaba Cloud account has access permissions to all API operations. Using this AccessKey pair is highly risky. We recommend that you create and use a Resource Access Management (RAM) user to invoke API operations or perform routine O&M. The RAM user must have permissions to perform operations on Simple Log Service resources. For more information, see Create a RAM user and grant permissions.

  • Identify the name and region of the project to which the logs you query belong. For more information about how to query, see Manage projects.

  • You can create up to 200 Logstores in a project.

  • Logs are deleted when the log retention period reaches the data retention period that you specify.

Authorization resources

The following table lists the authorization information for this API operation. You can add this information to the Action element of a RAM policy statement to grant Resource Access Management (RAM) users or RAM roles the permissions to invoke this API operation.

ActionResource
log:CreateLogStoreacs: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 name of the project.

ali-test-project

body

object

Yes

The request parameters.

logstoreName

string

Yes

The name of the Logstore. The name must meet the following rules:

  • The Logstore name must be unique within the same 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 in length.

my-logstore

shardCount

integer

Yes

The number of shards.

Note

This operation does not support updating the number of shards. You can modify the number of shards only by calling the SplitShard or MergeShards operation.

2

ttl

integer

Yes

The data retention period. Unit: days. Valid values: 1 to 3650. A value of 3650 indicates permanent retention.

1

encrypt_conf EncryptConf

No

The encryption configuration structure, which includes the enable, encrypt_type, and user_cmk_info parameters. For more information, see EncryptConf.

Example 1 (Enable default encryption configuration):

{
    "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 sharding. After this feature is enabled, if the log write traffic continuously exceeds the limit, automatic sharding is triggered to improve the write capacity. When you enable automatic sharding, you must configure the maxSplitShard parameter.

true

enable_tracking

boolean

No

Specifies whether to enable the WebTracking feature. Default value: false. You can use the WebTracking feature to collect and analyze user behavior data in browsers or mini programs, such as page views, purchase records, and time on site.

false

maxSplitShard

integer

No

The maximum number of shards for automatic sharding. Minimum value: 1. Maximum value: 256.

Note

This parameter is required when the autoSplit parameter is set to true.

64

appendMeta

boolean

No

Specifies whether to record the public IP address and log receiving time. Default value: false.

  • true: enables the feature to record the public IP address and log receiving time. After this feature is enabled, Simple Log Service automatically adds the public IP address of the device from which the logs originate and the time when the logs arrive at the server to the tag field of the logs.

  • false: disables the feature to record the public IP address and log receiving time.

false

telemetryType

string

No

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

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

  • Metrics: time series data.

None

hot_ttl

integer

No

The retention period of data in the hot tier of the Logstore. Unit: days. Minimum value: 7. The maximum value cannot exceed the value of the ttl parameter. By default, all data is stored in the hot tier within the ttl period.

When the storage time of data exceeds the configured hot data retention period, the data is transitioned to the infrequent access (IA) tier. When you enable the IA tier, the hot data retention period must be at least 7 days. For more information, see Intelligent tiering.

Examples:

  • Scenario 1 (Enable only the hot tier for 30 days): {"ttl": 30} or {"ttl": 30, "hot_ttl": 30}

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

60

mode

string

No

Simple Log Service provides two types of Logstores: Standard and Query.

  • standard: supports the all-in-one data analytics feature of Simple Log Service. It 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 fee is about half of that of the Standard type, but SQL analysis is not supported. It is suitable for scenarios with large data volumes, long storage periods (weeks or months), and no log analysis requirements.

standard

infrequentAccessTTL

integer

No

The IA tier. No minimum retention period is required, but data must be retained for at least 30 days before being transitioned to the archive tier.

When the log retention period is greater than the sum of the hot tier retention period and the IA tier retention period, the remaining retention period is applied to the archive tier.

Examples:

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

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

  • Scenario 3 (Enable the hot tier for 60 days, the IA tier for 0 days, and the archive tier for 60 days): {"ttl": 120, "hot_ttl": 60, "infrequentAccessTTL": 0}

30

processorId

string

No

The ID of the write processor.

processor-nginx-parser-001

shardingPolicy ShardingPolicy

No

The hash write configuration. When data is written, logs are routed to shards based on the configured hash policy. Before configuration, ensure that the hash ranges of the shards are even. This may affect the write capacity, so configure it with caution.

resourceGroupId

string

No

The ID of the resource group. After you specify this parameter, the Logstore is associated with the resource group.

rg-xxxxxxxx

enableModify

boolean

No

Specifies whether to enable log modification and deletion.

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.