接口说明
调用addRule接口创建采集规则
请求头
该接口使用公共请求头,无特殊请求头。请参见公共请求参数文档。
请求语法
POST /paasopenapi/api/cmplogadmin/cmplog/collect/rule/add HTTP/1.1
请求参数
名称 | 类型 | 位置 | 是否必选 | 示例 | 描述 |
---|---|---|---|---|---|
name | String | body | 是 | 采集规则名称 | |
logPathJson | String | body | 是 | 采集路径 | |
collectPolicy | String | body | 是 | add | 采集策略,add:增量采集, all: 全量采集 |
unitId |
Long | body | 是 | 日志单元ID | |
extractMode | Byte | body | 否 | 提取模式,1-文本日志 2- CCSE标准输出 3-CCSE应用日志 | |
cuttingMode | String | body | 是 | 切割模式,1-单行正则,2-分隔符 3-多行正则 4-单行全文 5-json 6-多行全文 | |
resPoolCode | String | body | 否 | 资源池编码 | |
firstLinePattern | String | body | 否 | "\s+" | 首行正则表达式 |
delimeterVo | DelimeterVo | body | 否 | 分隔符信息,DelimeterVo数据结构见下表 | |
RegexVo | RegexVo | body | 否 | 正则分词信息,RegexVo数据结构见下表 | |
extractPattern | String | body | 否 | "\s+" | 提取正则表达式 |
RegexVo数据结构
eg | String | "2023-08-17-16:58:03:582 INFO InitializingExecutorService 'applicationTaskExecutor" | 日志样例数据 |
---|---|---|---|
firstLinePattern | String | "\s+" | 首行正则表达式 |
regexStr | String | "\s+" | 日志数据提取的正则表达式 |
logContent | List | "logContent":[ { "key":"time", "content":"2023-08-17-16:58:03:582", "type":"string" } ] | 日志提取内容;TypeContent数据结构如下:key:自定义的分词keycontent: 分词key对应的日志样例数据type : 分词key所对应的日志数据类型,可传string, double int bool |
DelimeterVo数据结构
eg | String | "2023-08-17-16:58:03:582 INFO InitializingExecutorService 'applicationTaskExecutor" | 日志样例数据 |
---|---|---|---|
delimeter | String | " | " |
logContent | List | "logContent":[ { "key":"time", "content":"2023-08-17-16:58:03:582", "type":"string" } ] | 日志提取内容;TypeContent数据结构如下:key:自定义的分词keycontent: 分词key对应的日志样例数据type : 分词key所对应的日志数据类型,可传string, double int bool |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
code | Integer | 0 | 响应状态码。0:成功,-1:失败 |
msg | String | 响应描述 | |
data | Long | ruleId |
示例
请求示例
POST /paasopenapi/api/cmplogadmin/cmplog/collect/rule/add HTTP/1.1
正常请求参数示例
{
"name":"addRule",
"collectPolicy":"all",
"logPathJson":"[{\"path\":\"/root/test.log\"}]",
"logPathBlacklistStatus":0,
"extractMode":1,
"cuttingMode":2,
"delimeterVo":{
"eg":"2023-08-17-16:58:03:582 INFO InitializingExecutorService 'applicationTaskExecutor'",
"logContent":[
{
"key":"time",
"content":"2023-08-17-16:58:03:582",
"type":"string",
"id":"041705664971"
},
{
"key":"level",
"content":"INFO",
"type":"string",
"id":"286827551293"
},
{
"key":"thread",
"content":"InitializingExecutorService",
"type":"string",
"id":"213162088088"
},
{
"key":"msg",
"content":"'applicationTaskExecutor'",
"type":"string",
"id":"749224666433"
}
],
"delimeter":" "
},
"filterStatus":0,
"unitId":1012,
"resPoolCode":"6019b5007a0b11eab5db0242ac110002"
}
错误码
HTTP状态码(Status Code) | 错误码(Error Code) | 描述(Description) |
---|---|---|
400 | MissingParameter | 缺少必要的请求参数。 |
400 | InvalidParameterValue | 请求参数取值错误。 |
500 | FailedOperation | 操作失败 |