调用CLI命令创建Logtail配置。

请求语法

aliyunlog log create_logtail_config --project_name=<value> --config_detail=<value> [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>]

请求参数

该命令的必选和特有参数描述如下。
参数名称 数值类型 是否必选 示例值 描述
--project_name String test Project名称。
--config_detail String file://./logtailconfig.json Logtail配置文件路径。更多信息,请参见Logtail配置
关于该命令的全局参数,请参见 全局参数

示例

  1. 创建logtailconfig.json文件,其中配置名称为config_name2。其内容示例如下:
    {
      "config_name": "config_name2",
      "logstore_name": "logstore-a",
      "file_pattern": "file_pattern",
      "time_format": "time_format",
      "log_path": "/log_path",
      "endpoint": "endpoint",
      "log_parse_regex": "xxx ([\\w\\-]+\\s[\\d\\:]+)\\s+(.*)",
      "log_begin_regex": "xxx.*",
      "reg_keys": [
        "time",
        "value"
      ],
      "topic_format": "none",
      "filter_keys": [
        "time",
        "value"
      ],
      "filter_keys_reg": [
        "time",
        "value"
      ],
      "logSample": "xxx 2017-11-11 11:11:11 hello alicloud."
    }
  2. 使用默认账号创建名称为config_name2的Logtail配置。
    aliyunlog log create_logtail_config --project_name="aliyun-test-project" --config_detail="file://./logtailconfig.json"
  3. 查询已创建的Logtail配置。命令示例如下:
    aliyunlog log get_logtail_config --project_name="aliyun-test-project" --config_name="config_name2"
    返回结果如下:
    { "configName": "config_name2",
      "createTime": 1622118681,
      "inputDetail": {
        "adjustTimezone": false,
        "delayAlarmBytes": 0,
        "delaySkipBytes": 0,
        "discardNonUtf8": false,
        "discardUnmatch": true,
        "dockerFile": false,
        "enableRawLog": false,
        "enableTag": false,
        "fileEncoding": "utf8",
        "filePattern": "file_pattern",
        "filterKey": [
          "time",
          "value"
        ],
        "filterRegex": [
          "time",
          "value"
        ],
        "key": [
          "time",
          "value"
        ],
        "localStorage": true,
        "logBeginRegex": "xxx.*",
        "logPath": "/log_path",
        "logTimezone": "",
        "logType": "common_reg_log",
        "maxDepth": 1000,
        "maxSendRate": -1,
        "mergeType": "topic",
        "preserve": true,
        "preserveDepth": 0,
        "priority": 0,
        "regex": "xxx ([\\w\\-]+\\s[\\d\\:]+)\\s+(.*)",
        "sendRateExpire": 0,
        "sensitive_keys": [],
        "tailExisted": false,
        "timeFormat": "time_format",
        "topicFormat": "none"
      },
      "inputType": "file",
      "lastModifyTime": 1622118681,
      "logSample": "xxx 2017-11-11 11:11:11 hello alicloud.",
      "outputDetail": {
        "endpoint": "cn-hangzhou-b-intranet.log.aliyuncs.com",
        "logstoreName": "logstore-a",
        "region": "cn-hangzhou-b"
      },
      "outputType": "LogService"
    }

错误码

如果返回报错信息,请参见具体接口的错误码处理。更多信息,请参见CreateConfig错误码处理

API参考

CreateConfig