ALIYUN::SLS::Logstore

更新时间:
复制 MD 格式

ALIYUN::SLS::Logstore creates a Logstore in a Simple Log Service (SLS) project.

Syntax

{
  "Type": "ALIYUN::SLS::Logstore",
  "Properties": {
    "ProjectName": String,
    "ShardCount": Integer,
    "AutoSplit": Boolean,
    "MaxSplitShard": Integer,
    "LogstoreName": String,
    "AppendMeta": Boolean,
    "TTL": Integer,
    "EnableTracking": Boolean,
    "PreserveStorage": Boolean,
    "EncryptConf": Map,
    "Mode": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

ProjectName

String

Yes

No

The SLS project in which to create the Logstore.

3 to 63 characters.

Can contain lowercase letters, digits, hyphens (-), and underscores (_). Must start and end with a lowercase letter or digit.

ShardCount

Integer

No

Yes

The number of shards.

Valid values: 1 to 100.

Default value: 2.

MaxSplitShard

Integer

No

Yes

The maximum number of shards for automatic splitting.

Valid values: 1 to 64.

Required when AutoSplit is set to true.

LogstoreName

String

Yes

No

The Logstore name.

Must be unique within the SLS project.

  • 3 to 36 characters.

  • Can contain lowercase letters, digits, hyphens (-), and underscores (_).

  • Must start and end with a lowercase letter or digit.

AutoSplit

Boolean

No

Yes

Whether to automatically split shards.

Valid values:

  • true

  • false (default)

TTL

Integer

No

Yes

The data retention period.

Valid values: 1 to 3600.

Default value: 30.

Unit: day.

EnableTracking

Boolean

No

Yes

Whether to enable web tracking.

Web tracking collects data from web browsers, iOS apps, and Android apps.

Valid values:

  • true

  • false (default)

PreserveStorage

Boolean

No

Yes

Whether to retain logs permanently.

Valid values:

  • true: retains logs permanently. TTL does not take effect when PreserveStorage is set to true.

  • false (default): does not retain logs permanently.

Mode

String

No

Yes

The Logstore type.

Valid values:

  • standard: Standard Logstore. Supports log analysis and is suitable for real-time monitoring and interactive analysis. You can use this type of Logstore to build a comprehensive observability system.

  • query: Query Logstore. Supports high-performance queries at about half the index traffic cost of a Standard Logstore. Does not support SQL analysis. Suitable for large data volumes, long retention periods, or scenarios where log analysis is not required. A long retention period means logs stored for weeks or months.

AppendMeta

Boolean

No

Yes

Whether to append the client public IP address and log arrival time after receiving a log.

Valid values:

  • true

  • false (default)

EncryptConf

Map

No

No

The data encryption configuration.

EncryptConf syntax and EncryptConf properties.

EncryptConf syntax

"EncryptConf": {
    "Enable": Boolean,
    "EncryptType": String,
    "UserCmkInfo": Map
}

EncryptConf properties

Property

Type

Required

Editable

Description

Constraint

Enable

Boolean

Yes

No

Whether to enable data encryption.

Valid values:

  • true

  • false (default)

EncryptType

String

Yes

No

The encryption algorithm.

Valid values:

  • default: Advanced Encryption Standard (AES) algorithm

  • m4: Chinese cryptographic algorithm

UserCmkInfo

Map

No

No

The BYOK method for data encryption and decryption. If empty, the SLS service key is used.

UserCmkInfo syntax and UserCmkInfo properties.

UserCmkInfo syntax

"UserCmkInfo": {
    "CmkKeyId": String,
    "Arn": String,
    "RegionId": String
  }

UserCmkInfo properties

Property

Type

Required

Editable

Description

Constraint

CmkKeyId

String

Yes

No

The ID of the customer master key (CMK) for BYOK encryption.

None.

RegionId

String

Yes

No

The region ID of the CMK.

None.

Arn

String

Yes

No

The Alibaba Cloud Resource Name (ARN) of the RAM role.

To query the ARN of a RAM role, see Ship log data from Simple Log Service to OSS.

Return values

Fn::GetAtt

  • LogstoreName: the Logstore name.

  • ProjectName: the SLS project name.

Examples

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Description: Test SLS Logstore
Parameters: {}
Resources:
  SlsLogStore:
    Type: ALIYUN::SLS::Logstore
    Properties:
      LogstoreName: mytest
      PreserveStorage: true
      ProjectName: TestProject
      AppendMeta: true
      MaxSplitShard: 64
      AutoSplit: true
      EnableTracking: false
      ShardCount: 2
Outputs: {}

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test SLS Logstore",
  "Parameters": {
  },
  "Resources": {
    "SlsLogStore": {
      "Type": "ALIYUN::SLS::Logstore",
      "Properties": {
        "LogstoreName": "mytest",
        "PreserveStorage": true,
        "ProjectName": "TestProject",
        "AppendMeta": true,
        "MaxSplitShard": 64,
        "AutoSplit": true,
        "EnableTracking": false,
        "ShardCount": 2
      }
    }
  },
  "Outputs": {
  }
}

For more examples, visit sls.yml. The following resource types are used: ALIYUN::SLS::Project, ALIYUN::SLS::Logstore, ALIYUN::SLS::Index, ALIYUN::SLS::LogtailConfig, ALIYUN::SLS::MachineGroup, ALIYUN::SLS::ApplyConfigToMachineGroup, ALIYUN::ApiGateway::LogConfig, ALIYUN::SLS::Savedsearch, and ALIYUN::SLS::Alert.