数据打点
请求路径:/api/v1/data
请求方法: POST
请求体示例:
POST /api/v1/data?host=<hostname>&repo=<test_repo>&sourcetype=
<test_sourcetype>&origin=<origin>&collectTime=<collectTime>
Header: Content-Type: application/json
[
{
"raw": "this is a log",
"repo": "test_repo",
"sourcetype": "test_sourcetype",
"host": "hostname",
"origin": "origin",
"collectTime": 1582619883000,
"timestamp": 1582619883000
},
...
]
请求体参数说明:
字段名称 | 类型 | 含义 | 必选 | 说明 |
---|---|---|---|---|
raw | string | 数据内容 | 是 | 日志内容 |
repo | string | 仓库名称 | 否 | 当数据中省略该字段时,必须在 url 中增加该字段默认值 |
sourcetype | string | 来源类型 | 否 | 当数据中省略该字段时,必须在 url 中增加该字段默认值 |
host | string | hostname | 否 | 辅助字段,数据来源机器的 hostname |
origin | string | origin | 否 | 辅助字段,数据来源,⽐如⽂件名等 |
collectTime | long | 收集时间 | 否 | ⽇志收集时间,必须为 13 位时间戳 |
timestamp | long | 数据时间 | 否 | 当为空时,会根据 sourcetype 的配置从数据中提取 |
响应体示例:
{
"total": 123,
"success": 121,
"failure": 2,
"detail": [
{
"startPos": 2,
"endPos": 3,
"status": 404,
"message": "sourcetype not found"
}, {
"startPos": 10,
"endPos": 11,
"status": 404,
"message": "repo not found"
}
]
}
响应体参数说明:
字段名称 | 类型 | 含义 | 说明 |
---|---|---|---|
total | int | 请求中的日志总数 | 数量与请求中的数组元素个数相同 |
success | int | 成功条数 | 成功被索引的数据条数 |
failure | int | 失败条数 | 无法被索引的数据条数 |
detail | array | 失败数据详情 | 数组⻓度应与 failure 相同 |
startPos | int | 失败数据下标 | 该数值对应请求中数组的元素位置 |
endPos | int | - | 该字段忽略 |
status | int | 失败 code | 404、500 等 |
message | string | 失败原因 | 失败具体原因 |
文档反馈
(如有产品使用问题,请提交工单)