156
阿里云
CreateConfig__Logtail配置相关接口_API-Reference_日志服务-阿里云
在Project下创建Config
示例:
POST /configs
请求语法
POST /configs HTTP/1.1Authorization: <AuthorizationString>Content-Type:application/jsonContent-Length:<Content Length>Content-MD5<:<Content MD5>Date: <GMT Date>Host: <Project Endpoint>x-log-apiversion: 0.6.0x-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.1Header :{'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 OKHeader{'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-阿里云