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配置名称。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test SLS Project、Logstore、Alert、Index、LogtailConfig、MachineGroup、ApplyConfigToMachineGroup、ApiGatewayLogConfig",
  "Parameters": {
    "SlsProjectName": {
      "Type": "String",
      "MinLength": 3,
      "MaxLength": 63,
      "Default": "mytest"
    },
    "SlsLogStoreName": {
      "Type": "String",
      "MinLength": 3,
      "MaxLength": 63,
      "Default": "mytest"
    },
    "LogtailConfigName": {
      "MinLength": 3,
      "Type": "String",
      "MaxLength": 63,
      "Default": "mytest"
    }
  },
  "Resources": {
    "SlsProject": {
      "Type": "ALIYUN::SLS::Project",
      "Properties": {
        "Description": "Test SLS Project",
        "Name": {
          "Ref": "SlsProjectName"
        }
      }
    },
    "SlsLogStore": {
      "Type": "ALIYUN::SLS::Logstore",
      "DependsOn": "SlsProject",
      "Properties": {
        "LogstoreName": {
          "Ref": "SlsLogStoreName"
        },
        "PreserveStorage": true,
        "ProjectName": {
          "Fn::GetAtt": [
            "SlsProject",
            "Name"
          ]
        },
        "AppendMeta": true,
        "MaxSplitShard": 64,
        "AutoSplit": true,
        "EnableTracking": false,
        "ShardCount": 2
      }
    },
    "LogIndex": {
      "Type": "ALIYUN::SLS::Index",
      "DependsOn": "SlsLogStore",
      "Properties": {
        "ProjectName": {
          "Fn::GetAtt": [
            "SlsProject",
            "Name"
          ]
        },
        "FullTextIndex": {
          "CaseSensitive": true
        },
        "LogstoreName": {
          "Fn::GetAtt": [
            "SlsLogStore",
            "LogstoreName"
          ]
        }
      }
    },
    "LogtailConfig": {
      "Type": "ALIYUN::SLS::LogtailConfig",
      "DependsOn": "LogIndex",
      "Properties": {
        "ProjectName": {
          "Fn::GetAtt": [
            "SlsProject",
            "Name"
          ]
        },
        "LogtailConfigName": {
          "Ref": "LogtailConfigName"
        },
        "LogstoreName": {
          "Fn::GetAtt": [
            "SlsLogStore",
            "LogstoreName"
          ]
        },
        "RawConfigData": {
          "configName": {
            "Ref": "LogtailConfigName"
          },
          "outputType": "LogService",
          "inputType": "file",
          "inputDetail": {
            "logPath": "/logPath",
            "filePattern": "access.log",
            "logType": "json_log",
            "topicFormat": "default",
            "discardUnmatch": false,
            "enableRawLog": true,
            "fileEncoding": "utf8",
            "maxDepth": 10
          },
          "outputDetail": {
            "projectName": {
              "Fn::GetAtt": [
                "SlsProject",
                "Name"
              ]
            },
            "logstoreName": {
              "Fn::GetAtt": [
                "SlsLogStore",
                "LogstoreName"
              ]
            }
          }
        }
      }
    }
  },
  "Outputs": {
    "SlsProjectName": {
      "Value": {
        "Fn::GetAtt": [
          "SlsProject",
          "Name"
        ]
      }
    },
    "SlsLogStoreName": {
      "Value": {
        "Fn::GetAtt": [
          "SlsLogStore",
          "LogstoreName"
        ]
      }
    }
  }
}

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