配置如下,httpinput用来搜集http请求连接返回的数据。
[hekad]
maxprocs = 2
[HttpInput]
url = "http://www.bejson.com/"
ticker_interval = 5
success_severity = 6
error_severity = 1
[HttpInput.headers] --header配置,默认agent 是heka
user-agent = "MyCustomUserAgent"
log输出显示。
[RstEncoder]
[LogOutput]
message_matcher = "TRUE"
encoder = "RstEncoder
启动返回的结果。
:Timestamp: 2016-07-21 08:24:08.38507242 +0000 UTC
:Type: heka.httpinput.data
:Hostname: master
:Pid: 0
:Uuid: be01d3ea-308c-419e-ba54-917f53ca778d
:Logger: http://www.bejson.com/
:Payload: <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">.......
</body></html>
:EnvVersion:
:Severity: 6
:Fields:
| name:"StatusCode" type:integer value:200
| name:"Status" type:string value:"200 OK"
| name:"ResponseSize" type:integer value:0 representation:"B"
| name:"ResponseTime" type:double value:0.025777886000000003 representation:"s"
| name:"Protocol" type:string value:"HTTP/1.1"
正如官方文档描述,http请求的结果放在了payload,而http的状态,则放在了Filed中。
官方文档的例子:
[HttpInput] url = "http://localhost:9876/" ticker_interval = 5 success_severity = 6 error_severity = 1 decoder = "MyCustomJsonDecoder" [HttpInput.headers] user-agent = "MyCustomUserAgent"
看来使用了jsondecoder对返回的结果进行json解析,即对payload中的内容进行解析,显然是html的文档,解析会出问题,报错。如果http是接口,返回的数据是json形式的,估计可以使用jsondecoder解析,那么解析之后,生成新的数据,httpinput返回的fileds数据,估计就没了,除非自定义decoder,加上http状态返回的信息,所以例子中给的是MyCustomJsonDecorder而没有使用默认的JsonDecorder...