ALIYUN::SLS::Logstore类型用于在日志项目下创建日志库。

语法

{
  "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
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
ProjectName String 要创建的日志库所属日志项目的名称。

长度为3~36个字符。

支持小写英文字母、数字、短划线(-)、下划线(_)。必须以小写英文字母或数字开头和结尾。

ShardCount Integer 分区个数。

取值范围:1~100。

默认值:2。

单位:个。

MaxSplitShard Integer 自动分裂时,分裂出最大的分区个数。 取值范围:1~64。

当autoSplit为true时,必须指定MaxSplitShard。

LogstoreName String 日志库的名称。 在一个日志项目中,日志库的名称必须具有唯一性。
  • 长度为3~36个字符。
  • 支持小写英文字母、数字、短划线(-)、下划线(_)。
  • 必须以小写英文字母或数字开头和结尾。
AutoSplit Boolean 是否自动分裂分区。 取值:
  • true:自动分裂分区。
  • false(默认值):不自动分裂分区。
TTL Integer 数据的保存时间。 取值范围:1~3600。

默认值:30。

单位:天。

EnableTracking Boolean 是否开启WebTracking采集信息。

支持采集各种浏览器以及iOS或Android App的信息。

取值:
  • true:开启WebTracking采集信息。
  • false(默认值):不开启WebTracking采集信息。
PreserveStorage Boolean 是否永久保存日志。 取值:
  • true:永久保存日志。如果取值为true,则TTL的设置不生效。
  • false(默认值):不永久保存日志。
AppendMeta Boolean 接收日志后,是否自动添加客户端外网IP和日志到达时间。 取值:
  • true:自动添加客户端外网IP和日志到达时间。
  • false(默认值):不自动添加客户端外网IP和日志到达时间。
EncryptConf Map 数据加密配置。

更多信息,请参见EncryptConf语法EncryptConf属性

EncryptConf语法

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

EncryptConf属性

属性名称 类型 必须 允许更新 描述 约束
Enable Boolean 是否启用数据加密。 取值:
  • true:启用数据加密。
  • false(默认值):不启用数据加密。
EncryptType String 加密算法。 取值:
  • default:AES算法。
  • m4:国密算法。
说明 关于数据加密的更多信息,请参见数据加密
UserCmkInfo Map 如果指定了UserCmkInfo,则使用自带密钥(BYOK)加密或解密数据。否则,将使用日志服务的服务密钥。

更多信息,请参见UserCmkInfo语法UserCmkInfo属性

UserCmkInfo语法

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

UserCmkInfo属性

属性名称 类型 必须 允许更新 描述 约束
CmkKeyId String BYOK密钥所属的CMK的ID。
Arn String CMK所在区域的ID。
RegionId String RAM角色的ARN。 关于如何获取RAM角色的ARN的更多信息,请参见将日志服务数据投递到OSS

返回值

Fn::GetAtt

LogstoreName:日志库名称。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "LogstoreName": {
      "Type": "String",
      "Description": "Logstore name:\n1. Only supports lowercase letters, numbers, hyphens (-) and underscores (_).\n2. Must start and end with lowercase letters and numbers.\n3. The name length is 3-63 characters.",
      "MinLength": 3,
      "MaxLength": 63
    },
    "PreserveStorage": {
      "Type": "Boolean",
      "Description": "Whether to keep the log permanently.\nIf set to true, TTL will be ignored.\nDefault to false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "ProjectName": {
      "Type": "String",
      "Description": "Project name:\n1. Only supports lowercase letters, numbers, hyphens (-) and underscores (_).\n2. Must start and end with lowercase letters and numbers.\n3. The name length is 3-63 characters.",
      "AllowedPattern": "^[a-zA-Z0-9_-]+$",
      "MinLength": 3,
      "MaxLength": 63
    },
    "AppendMeta": {
      "Type": "Boolean",
      "Description": "Whether to add client external network IP and log arrival time after receiving the log.\nDefault to false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "MaxSplitShard": {
      "Type": "Number",
      "Description": "The maximum number of shards when splitting automatically. Must be specified if AutoSplit is set to true.\nAllowed Values: 1-64.",
      "MinValue": 1,
      "MaxValue": 64
    },
    "AutoSplit": {
      "Type": "Boolean",
      "Description": "Whether to automatically split the shard.\nDefault to false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "EnableTracking": {
      "Type": "Boolean",
      "Description": "Whether to enable WebTracking, which supports fast capture of various browsers and iOS/Android/APP access information.\nDefault to false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "EncryptConf": {
      "Type": "Json",
      "Description": "Data encryption config"
    },
    "TTL": {
      "Type": "Number",
      "Description": "The lifecycle of log in the logstore in days.\nAllowed Values: 1-3600, default to 30.",
      "MinValue": 1,
      "MaxValue": 3600,
      "Default": 30
    },
    "ShardCount": {
      "Type": "Number",
      "Description": "The number of Shards.\nAllowed Values: 1-100, default to 2.",
      "MinValue": 1,
      "MaxValue": 100,
      "Default": 2
    }
  },
  "Resources": {
    "Logstore": {
      "Type": "ALIYUN::SLS::Logstore",
      "Properties": {
        "LogstoreName": {
          "Ref": "LogstoreName"
        },
        "PreserveStorage": {
          "Ref": "PreserveStorage"
        },
        "ProjectName": {
          "Ref": "ProjectName"
        },
        "AppendMeta": {
          "Ref": "AppendMeta"
        },
        "MaxSplitShard": {
          "Ref": "MaxSplitShard"
        },
        "AutoSplit": {
          "Ref": "AutoSplit"
        },
        "EnableTracking": {
          "Ref": "EnableTracking"
        },
        "EncryptConf": {
          "Ref": "EncryptConf"
        },
        "TTL": {
          "Ref": "TTL"
        },
        "ShardCount": {
          "Ref": "ShardCount"
        }
      }
    }
  },
  "Outputs": {
    "LogstoreName": {
      "Description": "Logstore name.",
      "Value": {
        "Fn::GetAtt": [
          "Logstore",
          "LogstoreName"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  AppendMeta:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
    Description: 'Whether to add client external network IP and log arrival time after
      receiving the log.

      Default to false.'
    Type: Boolean
  AutoSplit:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
    Description: 'Whether to automatically split the shard.

      Default to false.'
    Type: Boolean
  EnableTracking:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
    Description: 'Whether to enable WebTracking, which supports fast capture of various
      browsers and iOS/Android/APP access information.

      Default to false.'
    Type: Boolean
  EncryptConf:
    Description: Data encryption config
    Type: Json
  LogstoreName:
    Description: 'Logstore name:

      1. Only supports lowercase letters, numbers, hyphens (-) and underscores (_).

      2. Must start and end with lowercase letters and numbers.

      3. The name length is 3-63 characters.'
    MaxLength: 63
    MinLength: 3
    Type: String
  MaxSplitShard:
    Description: 'The maximum number of shards when splitting automatically. Must
      be specified if AutoSplit is set to true.

      Allowed Values: 1-64.'
    MaxValue: 64
    MinValue: 1
    Type: Number
  PreserveStorage:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
    Description: 'Whether to keep the log permanently.

      If set to true, TTL will be ignored.

      Default to false.'
    Type: Boolean
  ProjectName:
    AllowedPattern: ^[a-zA-Z0-9_-]+$
    Description: 'Project name:

      1. Only supports lowercase letters, numbers, hyphens (-) and underscores (_).

      2. Must start and end with lowercase letters and numbers.

      3. The name length is 3-63 characters.'
    MaxLength: 63
    MinLength: 3
    Type: String
  ShardCount:
    Default: 2
    Description: 'The number of Shards.

      Allowed Values: 1-100, default to 2.'
    MaxValue: 100
    MinValue: 1
    Type: Number
  TTL:
    Default: 30
    Description: 'The lifecycle of log in the logstore in days.

      Allowed Values: 1-3600, default to 30.'
    MaxValue: 3600
    MinValue: 1
    Type: Number
Resources:
  Logstore:
    Properties:
      AppendMeta:
        Ref: AppendMeta
      AutoSplit:
        Ref: AutoSplit
      EnableTracking:
        Ref: EnableTracking
      EncryptConf:
        Ref: EncryptConf
      LogstoreName:
        Ref: LogstoreName
      MaxSplitShard:
        Ref: MaxSplitShard
      PreserveStorage:
        Ref: PreserveStorage
      ProjectName:
        Ref: ProjectName
      ShardCount:
        Ref: ShardCount
      TTL:
        Ref: TTL
    Type: ALIYUN::SLS::Logstore
Outputs:
  LogstoreName:
    Description: Logstore name.
    Value:
      Fn::GetAtt:
      - Logstore
      - LogstoreName

更多示例,请参见创建日志项目、创建日志库、创建索引、配置Logtail参数、创建日志服务ECS机器组、将日志配置应用于机器组、创建日志配置、将查询结果保存为快速查询和创建告警的组合示例:JSON示例YAML示例