Opentsdb http 寫入常見問題

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 requests
2.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的使用示例,大家可以自己去學習。

這裏寫圖片描述

好啦好啦,今天就說這麼多!告辭!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章