Skip to content

Http Sender

Sun Jianbo edited this page Jul 16, 2018 · 5 revisions

Http Sender 是 logkit 提供的以 http post 请求的方式发送数据的形式

典型配置如下

"sender":{
    "sender_type":"http",
    "http_sender_url": "127.0.0.1:4001/logkit/data",
    "http_sender_gzip": "true",
    "http_sender_protocol": "json",
    "http_sender_csv_head": "true",
    "http_sender_csv_split": "\t"
}

配置参数说明

  1. http_sender_url: 必填, post 请求发送的路径
  2. http_sender_gzip: 选填, 发送时启用 gzip, 默认开启
  3. http_sender_protocol: 选填, 发送的数据格式, 有 jsoncsvbody_json 三种选择, 默认为 json
  4. http_sender_csv_head: 选填, 若值为 true, 则使用 csv 发送时第一行为每一列的列名称, 默认为 true
  5. http_sender_csv_split: 选填, 使用 csv 发送时, 不同列之前的分隔符, 默认为 \t

csv 格式的数据样例

http_sender_csv_head 为 true 时,

name timestamp value age
jack 1529980502 hehe 21
mark 1529980413 nini 19
yell 1529980123 xsxs 30

http_sender_csv_head 为 false 时,

jack 1529980502 hehe 21
mark 1529980413 nini 19
yell 1529980123 xsxs 30

json 格式的数据样例

{"name":"jack","timestamp":1529980502,"value":"hehe","age":21}
{"name":"mark","timestamp":1529980413,"value":"nini","age":19}
{"name":"yell","timestamp":1529980123,"value":"xsxs","age":30}

选择 json 格式后,http sender的 body 每行都是一个json,多行用换行符\n分隔,读取时请按行读取,对于单行按json格式解析。

body_json 格式的数据样例

[{"name":"jack","timestamp":1529980502,"value":"hehe","age":21},
{"name":"mark","timestamp":1529980413,"value":"nini","age":19},
{"name":"yell","timestamp":1529980123,"value":"xsxs","age":30}]

选择 body_json格式表示整个发送的body都是json格式

Clone this wiki locally