Opentsdb http 写入常见问题

来源:互联网 发布:matlab量化交易源码 编辑:程序博客网 时间:2024/06/06 03:29

1.存入的Opentsdb的时间戳,一定不能为0

metric=CID_1 ts=0 value=0.0 sn= 946168002784 carid=038588c0770840d0bf469b6149dbdce1

如果上方那个时间戳为0的话,存入Opentsdb会返回状态码400,提示你错误。

2. Invalid tag value (” 946168002784”): illegal character: : metric=CID_1 ts=1512413510 value=0.0 sn= 946168002784 carid=038588c0770840d0bf469b6149dbdce1

这个可能大家觉得没什么错误啊,你看946168002784前面,是不是空着一格,所以在插入json数据的时候,千万不要加空格,检查一下不要有空格的存在。

3. Received an unsupported chunked request: DefaultHttpRequest(chunked: true)

POST /api/put HTTP/1.1
Content-Length: 9346
Content-Type: application/json;charset=utf-8
Host: 192.168.207.28:4242
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5 (Java/1.8.0_91)
Accept-Encoding: gzip,deflate

1.adding "tsd.http.request.enable_chunked = true" to the config file, so that it doesn't reject chunked requests and adding "tsd.http.request.max_chunk = " to the config file, and setting it to a sensible size for your requests2.If you can change the client, force it to send smaller requests

最简单的方法就是在配置文件中加上这个

tsd.http.request.enable_chunked = true

4. ConnectionManager: Unexpected exception from downstream for [id: 0x17dcbeaf, /111.111.111.111:49177 => /666.666.666.666:4242]org.jboss.netty.handler.codec.frame.TooLongFrameException: HTTP content length exceeded 4096 bytes.

length exceeded这句话的意思就是长度超过规定的值4096字节,然后我去官网看了下默认配置
这里写图片描述

可以看到,http传输规定的最大值就是4096字节,然后我修改了配置,如下图

tsd.http.request.max_chunk = 163840改成163840字节,然后从新跑起来我自己写的程序,美滋滋。没事了。

以上全是针对HTTP接口出现的错误的总结,其实写入数据,SDK也可以,而且源码中,SDK的接口已经有使用示例啦,很方便的,如下图,这就是SDK的使用示例,大家可以自己去学习。

这里写图片描述

好啦好啦,今天就说这么多!告辞!

原创粉丝点击