156
windows
CreateConfig__Logtail配置相關接口_API-Reference_日誌服務-阿裏雲
在Project下創建Config
示例:
POST /configs
請求語法
POST /configs 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",
"logBeginRegex": ".*",
"regex": "(w+)(s+)",
"key" :["key1", "key2"],
"filterKey":["key1"],
"filterRegex":["regex1"],
"fileEncoding":"utf8",
"topicFormat": "none"
},
"outputType": "LogService",
"outputDetail":
{
"logstoreName": "perfcounter"
}
}
請求參數
屬性名稱 | 類型 | 是否必須 | 描述 | |
---|---|---|---|---|
configName | string | 是 | 日誌配置名稱, Project下唯一 | |
inputType | string | 是 | 輸入類型,現在隻支持”file” | |
inputDetail | json | 是 | 見下表格說明 | |
outputType | string | 是 | 輸出類型,現在隻支持”LogService” | |
outputDetail | json | 是 | 見下表格說明 | |
logSample | string | 否 | Logtail配置日誌樣例,最大支持1000字節 |
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生成方式,支持四種類型:1)用於將日誌文件路徑的某部分作為topic,如/var/log/(.*).log;2)none,表示topic為空;3)default,表示將日誌文件路徑作為topic;4)group_topic,表示將應用該配置的機器組topic屬性作為topic。 |
preserve | boolean | 否 | true代表監控目錄永不超時,false代表監控目錄30分鍾超時,默認值為true |
preserveDepth | integer | 否 | 當設置preserve為false時,指定監控不超時目錄的深度,最大深度支持3 |
fileEncoding | string | 否 | 支持兩種類型:”utf8”、”gbk” |
outputDetail內容:
屬性名稱 | 類型 | 必須 | 描述 |
---|---|---|---|
logstoreName | string | 是 | 對應logstore名字 |
請求頭
無特有請求頭,關於API的公共請求頭請參考公共請求頭。
響應頭
無特有響應頭,關於API的公共響應頭請參考公共響應頭。
響應元素
HTTP狀態碼返回200
錯誤碼
除了返回API的通用錯誤碼,還可能返回如下特有錯誤碼:
HTTP狀態碼 | ErrorCode | ErrorMessage |
---|---|---|
400 | ConfigAlreadyExist | config {Configname} already exist |
400 | InvalidParameter | invalid config resource json |
500 | InternalServerError | internal server error |
細節描述
創建過程中遇到配置已經存在、格式錯誤、必要參數遺失、或者quota超過限製等錯誤,則會創建失敗
示例
請求示例:
POST /configs HTTP/1.1
Header :
{
'Content-Length': 737,
'Host': 'ali-test-project.cn-hangzhou-devcommon-intranet.sls.aliyuncs.com',
'x-log-bodyrawsize': 737,
'Content-MD5': 'FBA01ECF7255BE143379BC70C56BBF68',
'x-log-signaturemethod': 'hmac-sha1',
'Date': 'Mon, 09 Nov 2015 07:45:30 GMT',
'x-log-apiversion': '0.6.0',
'User-Agent': 'log-python-sdk-v-0.6.0',
'Content-Type': 'application/json',
'Authorization': 'LOG 94to3z418yupi6ikawqqd370:x/L1ymdn9wxe2zrwzcdSG82nXL0='
}
Body:
{
"configName": "sample-logtail-config",
"inputType": "file",
"inputDetail": {
"logType": "common_reg_log",
"logPath": "/var/log/httpd/",
"filePattern": "access*.log",
"localStorage": true,
"timeFormat": "%d/%b/%Y:%H:%M:%S",
"logBeginRegex": "\d+\.\d+\.\d+\.\d+ - .*",
"regex": "([\d\.]+) \S+ \S+ \[(\S+) \S+\] "(\w+) ([^"]*)" ([\d\.]+) (\d+) (\d+) (\d+|-) "([^"]*)" "([^"]*)".*",
"key": ["ip", "time", "method", "url", "request_time", "request_length", "status", "length", "ref_url", "browser"],
"filterKey": [],
"filterRegex": [],
"topicFormat": "none",
"fileEncoding": "utf8"
},
"outputType": "LogService",
"outputDetail":
{
"logstoreName": "sls-test-logstore"
}
}
響應示例:
HTTP/1.1 200 OK
Header
{
'date': 'Mon, 09 Nov 2015 07:45:30 GMT',
'connection': 'close',
'x-log-requestid': '56404F1A99248CA26C002180',
'content-length': '0',
'server': 'nginx/1.6.1'
}
最後更新:2016-11-23 16:04:03
上一篇:
GetAppliedConfigs__Logtail機器組相關接口_API-Reference_日誌服務-阿裏雲
下一篇:
ListConfig__Logtail配置相關接口_API-Reference_日誌服務-阿裏雲
SetRule__轉發規則相關API_API 參考_負載均衡-阿裏雲
通用圖像分析服務簡介__通用圖像分析服務_人工智能圖像類-阿裏雲
彈性Web托管服務條款__產品相關問題_使用問題_彈性 Web 托管-阿裏雲
庫名不同的數據庫之間的數據遷移__最佳實踐_數據傳輸-阿裏雲
LogSearch-報警__Getting-Started_日誌服務-阿裏雲
查詢實例管理終端地址__實例相關接口_API 參考_雲服務器 ECS-阿裏雲
步驟三:實驗數據上傳和加工__快速入門_推薦引擎-阿裏雲
發起路由器接口連接__高速通道相關接口_API 參考_雲服務器 ECS-阿裏雲
什麼是雲服務器 ECS__產品簡介_雲服務器 ECS-阿裏雲
編輯鍵__數據管理_DMS for Redis_用戶指南(NoSQL)_數據管理-阿裏雲
相關內容
常見錯誤說明__附錄_大數據計算服務-阿裏雲
發送短信接口__API使用手冊_短信服務-阿裏雲
接口文檔__Android_安全組件教程_移動安全-阿裏雲
運營商錯誤碼(聯通)__常見問題_短信服務-阿裏雲
設置短信模板__使用手冊_短信服務-阿裏雲
OSS 權限問題及排查__常見錯誤及排除_最佳實踐_對象存儲 OSS-阿裏雲
消息通知__操作指南_批量計算-阿裏雲
設備端快速接入(MQTT)__快速開始_阿裏雲物聯網套件-阿裏雲
查詢API調用流量數據__API管理相關接口_API_API 網關-阿裏雲
使用STS訪問__JavaScript-SDK_SDK 參考_對象存儲 OSS-阿裏雲