837
阿里云
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
上一篇:
DeleteConfig__Logtail配置相关接口_API-Reference_日志服务-阿里云
下一篇:
资源列表__RAM子用户访问_API-Reference_日志服务-阿里云
1. OCS快速开始__开放缓存OCS 体验_体验馆-阿里云
查询日志__logsearch_用户指南_日志服务-阿里云
获取主域名名称__域名管理接口_API文档_云解析-阿里云
C#/.NET: EnyimMemcached__客户端连接实例_快速入门_云数据库 Memcache 版-阿里云
实例状态图__附录_API 参考_云服务器 ECS-阿里云
路由服务常见问题__常见问题_产品使用问题_容器服务-阿里云
Subscription__基本概念_API使用手册_消息服务-阿里云
附录三 常见错误码表__附录_使用手册_分析型数据库-阿里云
根据标签检索__标签_用户指南_云服务器 ECS-阿里云
ALIYUN::ECS::BandwidthPackage__资源列表_资源编排-阿里云
相关内容
常见错误说明__附录_大数据计算服务-阿里云
发送短信接口__API使用手册_短信服务-阿里云
接口文档__Android_安全组件教程_移动安全-阿里云
运营商错误码(联通)__常见问题_短信服务-阿里云
设置短信模板__使用手册_短信服务-阿里云
OSS 权限问题及排查__常见错误及排除_最佳实践_对象存储 OSS-阿里云
消息通知__操作指南_批量计算-阿里云
设备端快速接入(MQTT)__快速开始_阿里云物联网套件-阿里云
查询API调用流量数据__API管理相关接口_API_API 网关-阿里云
使用STS访问__JavaScript-SDK_SDK 参考_对象存储 OSS-阿里云