Giter VIP home page Giter VIP logo

Comments (4)

wonderflow avatar wonderflow commented on June 4, 2024

发一下logkit http发送的数据样例,以及你期望接受的样例。
我这边是正常的,没有复现。

from logkit.

DyncKevin avatar DyncKevin commented on June 4, 2024

现在我升级到1.4.9了
以下日志是在http_sender.goz里函数convertToJsonBytes中添加的打印
log.Printf("the byte is:%s", byteData)
在网站https://www.json.cn/ 里检测提示 json格式不对。

{"localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","cpu__time_user":47521.79,"cpu__time_idle":3541637.95,"timestamp":"2018-05-25T12:42:26.299621073+08:00","hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64"}
{"osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","cpu__time_idle":3549618.79,"cpu__time_user":43599.41,"hostname":"localhost.localdomain"}
{"osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","cpu__time_user":43357.56,"cpu__time_idle":3550646.58,"hostname":"localhost.localdomain"}
{"cpu__time_user":45397.92,"cpu__time_idle":3542047.71,"timestamp":"2018-05-25T12:42:26.299621073+08:00","hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64"}
{"cpu__time_idle":3579724.88,"cpu__time_user":26289.75,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00"}
{"localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","cpu__time_user":26103.79,"cpu__time_idle":3580232.16,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64"}
{"timestamp":"2018-05-25T12:42:26.299621073+08:00","cpu__time_user":28456.26,"cpu__time_idle":3571864.61,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64"}
{"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","cpu__time_idle":3575817.55,"cpu__time_user":26194.66}
{"localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","cpu__time_user":286921.18,"cpu__time_idle":28491590.27,"timestamp":"2018-05-25T12:42:26.299621073+08:00","hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64"}
{"disk__used":14101798912,"disk__total":53660876800,"disk__free":39559077888,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00"}
{"core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","disk__total":8250957824,"disk__free":8250957824,"disk__used":0,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115"}
{"core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","disk__total":8267943936,"disk__free":8235560960,"disk__used":32382976,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115"}
{"disk__free":8199757824,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","disk__total":8267943936,"disk__used":68186112}
{"disk__total":8267943936,"osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00","hostname":"localhost.localdomain","disk__free":8267943936,"disk__used":0}
{"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","disk__used":14101798912,"disk__total":53660876800,"disk__free":39559077888,"localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00"}
{"core":"3.10.0-693.21.1.el7.x86_64","disk__total":517713920,"disk__free":134291456,"disk__used":383422464,"timestamp":"2018-05-25T12:42:26.299621073+08:00","hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115"}
{"disk__free":674955751424,"disk__used":262118273024,"disk__total":937074024448,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00"}
{"disk__used":49152,"disk__total":1653592064,"disk__free":1653542912,"hostname":"localhost.localdomain","osinfo":"GNU/Linux-Linux-amd64","localip":"192.168.1.115","core":"3.10.0-693.21.1.el7.x86_64","timestamp":"2018-05-25T12:42:26.299621073+08:00"}
{"mem__free":3061235712,"mem__used":10394816512,"osinfo":"GNU/Linux-Linux-amd64","core":"3.10.0-693.21.1.el7.x86_64","hostname":"localhost.localdomain","localip":"192.168.1.115","mem__available":6141075456,"mem__total":16535891968,"timestamp":"2018-05-25T12:42:26.299621073+08:00"}

我希望的就是正确的json格式

from logkit.

wonderflow avatar wonderflow commented on June 4, 2024

https://github.com/qiniu/logkit/wiki/Http-Sender

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

from logkit.

DyncKevin avatar DyncKevin commented on June 4, 2024

你新增的文档我看过了,还是不行。你们这个http发送的json并不是标准的json吧,我用express接收,body-parser 解析不了。
虽然每一个模块是json对象,但一起发送的时候就不是了。
另外,发送的请求中,contentencoding为什么是json,一般都是identity阿

另外,我自己测试的,
将发送的bodydata做如下处理:
strData := strings.Join(dataArray, ",")
byteData = make([]byte, len(strData)+2)
copy(byteData, "[")
copy(byteData[1:], strData[:])
byteData[1+len(strData)] = ']'
转换成数组的json,并且将req.Header.Set(ContentEncodingHeader, "json")改为“identity”
服务端才可以正常接收
麻烦你们看一下,谢谢

from logkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.