全部产品
Search
文档中心

资源编排:ALIYUN::SLS::LogtailConfig

更新时间:Apr 28, 2025

ALIYUN::SLS::LogtailConfig类型用于配置采集数据时的Logtail参数。

语法

{
  "Type": "ALIYUN::SLS::LogtailConfig",
  "Properties": {
    "ProjectName": String,
    "LogtailConfigName": String,
    "LogstoreName": String,
    "RawConfigData": Map,
    "CloneFrom": Map
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ProjectName

String

日志项目名称。

LogtailConfigName

String

Logtail配置名称。

同一项目下配置名称必须唯一。

长度为2~128个字符。必须以小写英文字母或者数字开头和结尾。可包含小写英文字母、数字、短划线(-)和下划线(_)。

LogstoreName

String

日志库名称。

RawConfigData

Map

原始配置数据。

格式与SLS API GetConfig的响应相同。

如果同时指定CloneFrom和RawConfigData,LogtailConfig的数据将会和RawConfigData合并,RawConfigData中的configName、outputType和outputDetail会被忽略。

取值示例:{"configName": "test-logtail-config", "createTime": 1574843554, "inputDetail": {"acceptNoEnoughKeys": false, "adjustTimezone": false, "advanced": { "force_multiconfig": false }, "autoExtend": true, "delayAlarmBytes": 0, "delaySkipBytes": 0, "discardNonUtf8": false, "discardUnmatch": false, "dockerExcludeEnv": {}, "dockerExcludeLabel": {}, "dockerFile": false, "dockerIncludeEnv": {}, "dockerIncludeLabel": {}, "enableRawLog": false, "enableTag": false, "fileEncoding": "utf8", "filePattern": "test.log*", "filterKey": [], "filterRegex": [], "key": [ "time", "logger", "level", "request_id", "user_id", "region_id", "content" ], "localStorage": true, "logPath": "/var/log/test", "logTimezone": "", "logType": "delimiter_log", "maxDepth": 100, "maxSendRate": -1, "mergeType": "topic", "preserve": true, "preserveDepth": 1, "priority": 0, "quote": "\u0001", "sendRateExpire": 0, "sensitive_keys": [], "separator": ",,,", "shardHashKey": [], "tailExisted": false, "timeFormat": "", "timeKey": "", "topicFormat": "none" }, "inputType": "file", "lastModifyTime": 1574843554, "logSample": "2019-11-27 10:48:23,160,,,MAIN,,,INFO,,,98DCC51D-BE5D-49C7-B3FD-37B2BAEFB296,,,123456789,,,cn-hangzhou,,,this is a simple test.", "outputDetail": { "endpoint": "cn-hangzhou-intranet.log.aliyuncs.com", "logstoreName": "test-logstore", "region": "cn-hangzhou"}, "outputType": "LogService"}

CloneFrom

Map

克隆其他日志项目的LogtailConfig。

CloneFrom和RawConfigData必须指定其中一个参数。

更多信息,请参见CloneFrom属性

CloneFrom语法

"CloneFrom": {
  "ProjectName": String,
  "LogtailConfigName": String
}

CloneFrom属性

属性名称

类型

必须

允许更新

描述

约束

ProjectName

String

日志项目名称。

LogtailConfigName

String

Logtail配置名称。

返回值

Fn::GetAtt

  • Endpoint:Endpoint地址。

  • AppliedMachineGroups:日志采集配置的机器列表。

  • LogtailConfigName:Logtail配置名称。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  SlsProject:
    Type: ALIYUN::SLS::Project
    Properties:
      Name:
        Fn::Sub: project-test-${ALIYUN::StackId}
  SlsLogtailConfig:
    Type: ALIYUN::SLS::LogtailConfig
    Properties:
      ProjectName:
        Ref: SlsProject
      LogtailConfigName: app01
      LogstoreName:
        Fn::GetAtt:
          - SlsLogStore
          - LogstoreName
      RawConfigData:
        configName: logtail-test
        outputDetail:
          compressType: ''
          logstoreName:
            Fn::GetAtt:
              - SlsLogStore
              - LogstoreName
        outputType: LogService
        logSample: ''
        inputDetail:
          sensitive_keys: []
          shardHashKey: []
          enableRawLog: false
          logType: common_reg_log
          filterRegex: []
          mergeType: topic
          dockerExcludeEnv: {}
          regex: (.*)
          sendRateExpire: 0
          discardNonUtf8: false
          maxSendRate: -1
          priority: 0
          preserveDepth: 1
          localStorage: true
          logTimezone: ''
          dockerIncludeEnv: {}
          preserve: true
          delayAlarmBytes: 0
          discardUnmatch: false
          logPath: /apsara/nuwa
          dockerExcludeLabel: {}
          topicFormat: none
          maxDepth: 10
          key:
            - content
          filePattern: '*.Log'
          timeFormat: ''
          dockerFile: true
          advanced:
            force_multiconfig: false
            k8s:
              ExternalEnvTag: {}
            collect_containers_flag: false
            tail_size_kb: 1024
          dockerIncludeLabel: {}
          delaySkipBytes: 0
          filterKey: []
          tailExisted: false
          adjustTimezone: false
          logBeginRegex: .*
          fileEncoding: utf8
          enableTag: false
        inputType: file
  SlsLogStore:
    Type: ALIYUN::SLS::Logstore
    Properties:
      ProjectName:
        Ref: SlsProject
      AutoSplit: true
      MaxSplitShard: 64
      LogstoreName: mytest
      AppendMeta: true
      ShardCount: 2
      EnableTracking: false
      PreserveStorage: true
Outputs: {}
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "SlsProject": {
      "Type": "ALIYUN::SLS::Project",
      "Properties": {
        "Name": {
          "Fn::Sub": "project-test-${ALIYUN::StackId}"
        }
      }
    },
    "SlsLogStore": {
      "Type": "ALIYUN::SLS::Logstore",
      "Properties": {
        "LogstoreName": "mytest",
        "PreserveStorage": true,
        "ProjectName": {
          "Ref": "SlsProject"
        },
        "AppendMeta": true,
        "MaxSplitShard": 64,
        "AutoSplit": true,
        "EnableTracking": false,
        "ShardCount": 2
      }
    },
    "SlsLogtailConfig": {
      "Type": "ALIYUN::SLS::LogtailConfig",
      "Properties": {
        "ProjectName": {
          "Ref": "SlsProject"
        },
        "LogtailConfigName": "app01",
        "LogstoreName": {
          "Fn::GetAtt": [
            "SlsLogStore",
            "LogstoreName"
          ]
        },
        "RawConfigData": {
          "configName": "logtail-test",
          "inputDetail": {
            "adjustTimezone": false,
            "advanced": {
              "collect_containers_flag": false,
              "force_multiconfig": false,
              "k8s": {
                "ExternalEnvTag": {}
              },
              "tail_size_kb": 1024
            },
            "delayAlarmBytes": 0,
            "delaySkipBytes": 0,
            "discardNonUtf8": false,
            "discardUnmatch": false,
            "dockerExcludeEnv": {},
            "dockerExcludeLabel": {},
            "dockerFile": true,
            "dockerIncludeEnv": {},
            "dockerIncludeLabel": {},
            "enableRawLog": false,
            "enableTag": false,
            "fileEncoding": "utf8",
            "filePattern": "*.Log",
            "filterKey": [],
            "filterRegex": [],
            "key": [
              "content"
            ],
            "localStorage": true,
            "logBeginRegex": ".*",
            "logPath": "/apsara/nuwa",
            "logTimezone": "",
            "logType": "common_reg_log",
            "maxDepth": 10,
            "maxSendRate": -1,
            "mergeType": "topic",
            "preserve": true,
            "preserveDepth": 1,
            "priority": 0,
            "regex": "(.*)",
            "sendRateExpire": 0,
            "sensitive_keys": [],
            "shardHashKey": [],
            "tailExisted": false,
            "timeFormat": "",
            "topicFormat": "none"
          },
          "inputType": "file",
          "logSample": "",
          "outputDetail": {
            "compressType": "",
            "logstoreName": {
              "Fn::GetAtt": [
                "SlsLogStore",
                "LogstoreName"
              ]
            }
          },
          "outputType": "LogService"
        }
      }
    }
  },
  "Outputs": {
  }
}