阅读837 返回首页    go 阿里云


UpdateConfig__Logtail配置相关接口_API-Reference_日志服务-阿里云

更新配置内容,如果配置被应用到机器组,对应机器也会同时更新。

示例:

PUT /configs/{configName}

请求语法

PUT /configs/<configName> HTTP/1.1
Authorization: <AuthorizationString> 
Content-Type:application/json
Content-Length:<Content Length>
Content-MD5<:<Content MD5>
Date: <GMT Date>
Host: <Project Endpoint>
x-log-apiversion: 0.6.0
x-log-signaturemethod: hmac-sha1

{
    "configName": "testcategory1",
    "inputType": "file",
    "inputDetail": {
        "logType": "common_reg_log",
        "logPath": "/var/log/httpd/",
        "filePattern": "access.log",
        "localStorage": true,
        "timeFormat": "%Y/%m/%d %H:%M:%S",
        "logBeginReg": ".*",
        "regex": "(w+)(s+)",
        "key" :["key1", "key2"],
        "filterKey":["key1"],
        "filterRegex":["regex1"],
        "topicFormat": "none"
    },
    "outputType": "LogService",
    "outputDetail": 
    {
        "logstoreName": "perfcounter"
    }
}

请求参数

属性名称 类型 是否必须 描述
configName string 日志配置名称, Project下唯一
inputType string 输入类型,现在只支持"file"
inputDetail json 见下表格说明
outputType string 输出类型,现在只支持"LogService"
outputDetail json 见下表格说明
inputDetail内容:
属性名称 类型 必须 描述
logType string 日志类型,现在只支持"common_reg_log"
logPath string 日志所在的父目录,例如 /var/logs/
filePattern string 日志文件的Pattern,例如 access*.log
localStorage boolean 是否打开本地缓存,在服务端之间链路断开情况下,本地可以缓存1GB日志
timeFormat string 日志时间格式, 如 "%Y/%m/%d %H:%M:%S"
logBeginRegex string 日志首行特征(正则表达式),由于匹配多行日志组成一条log的情况
regex string 日志对提取正则表达式
key array 日志提取后所生成Key
filterKey array 用于过滤日志所用到的key,只有key的值满足对应filterRegex列中设定的正则表达式日志才是符合要求的
filterRegex array 和每个filterKey对应的正正则表达式, filterRegex的长度和filterKey的长度必须相同
topicFormat string 用于将日志文件路径的某部分作为topic,如/var/log/(.*).log,默认为none,表示topic为空。
preserve boolean true代表监控目录永不超时,false代表监控目录30分钟超时,默认值为true
preserveDepth integer 当设置preserve为false时,指定监控不超时目录的深度,最大深度支持3
outputDetail内容:
属性名称 类型 必须 描述
logstoreName string 对应logstore名字

请求头

无特有请求头,关于API的公共请求头请参考公共请求头

响应头

无特有响应头,关于API的公共响应头请参考公共响应头

响应元素

返回值:成功返回200状态码

错误码

除了返回API的通用错误码,还可能返回如下特有错误码:

HTTP状态码 ErrorCode ErrorMessage
404 ConfigNotExist config {Configname} not exist
400 InvalidParameter invalid config resource json
400 BadRequest config resource configname not match request
500 InternalServerError internal server error

细节描述

创建过程中遇到格式错误、必要参数遗失、或者quota超过限制等错误,则会创建失败

示例

请求示例:
PUT /configs/logtail-config-sample
Header : 
{
    "Content-Length": 737,
    "Host": "ali-test-project.cn-hangzhou-devcommon-intranet.sls.aliyuncs.com",
    "x-log-bodyrawsize": 737,
    "Content-MD5": "431263EB105D584A5555762A81E869C0",
    "x-log-signaturemethod": "hmac-sha1",
    "Date": "Mon, 09 Nov 2015 09:14:32 GMT",
    "x-log-apiversion": "0.6.0",
    "User-Agent": "log-python-sdk-v-0.6.0",
    "Content-Type": "application/json", 
    "Authorization": "LOG 94to3z418yupi6ikawqqd370:GTPzFbLe8PZW0OFxTk/xMoCXA9E="
}
Body :
{
    "outputDetail": {
        "logstoreName": "sls-test-logstore"
    }, 
    "inputType": "file", 
    "inputDetail": {
        "regex": "([\d\.]+) \S+ \S+ \[(\S+) \S+\] "(\w+) ([^"]*)" ([\d\.]+) (\d+) (\d+) (\d+|-) "([^"]*)" "([^"]*)".*", 
        "filterKey": [], 
        "logPath": "/var/log/nginx/", 
        "logBeginRegex": "\d+\.\d+\.\d+\.\d+ - .*", 
        "logType": "common_reg_log", 
        "topicFormat": "none", 
        "localStorage": true, 
        "key": [
            "ip", 
            "time", 
            "method", 
            "url", 
            "request_time", 
            "request_length", 
            "status", 
            "length", 
            "ref_url", 
            "browser"
        ], 
        "filePattern": "access*.log", 
        "timeFormat": "%d/%b/%Y:%H:%M:%S",
        "filterRegex": []
    },
    "outputType": "LogService",
    "configName": "logtail-config-sample"
}
响应示例:
{
    "date": "Mon, 09 Nov 2015 09:14:32 GMT",
    "connection": "close",
    "x-log-requestid": "564063F899248CAA2300B778",
    "content-length": "0",
    "server": "nginx/1.6.1"
}

最后更新:2016-11-23 16:04:03

  上一篇:go DeleteConfig__Logtail配置相关接口_API-Reference_日志服务-阿里云
  下一篇:go 资源列表__RAM子用户访问_API-Reference_日志服务-阿里云