閱讀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_日誌服務-阿裏雲