Comments (4)
发一下logkit http发送的数据样例,以及你期望接受的样例。
我这边是正常的,没有复现。
from logkit.
现在我升级到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.
https://github.com/qiniu/logkit/wiki/Http-Sender
增加了文档: 选择 json
格式后,http sender的 body 每行都是一个json,多行用换行符\n
分隔,读取时请按行读取,对于单行按json格式解析。
from logkit.
你新增的文档我看过了,还是不行。你们这个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)
- 支持helm charts安装logkit到Kubernetes HOT 1
- 偶发数据重复 HOT 1
- go build 失败了
- github.com/qiniu/log 缺失 HOT 1
- 数据采集不一致,重复发送了
- 能否增加写入远程hdfs文件?
- 一行数据被截取成了两条 HOT 1
- Docker image hasn't been updated for over one year HOT 1
- 版本1.5.5,模拟http接收端失败后,在ft_log目录下发现backup_local_save.diskqueue.000000.dat的文件,开启http接收端后,日志正常采集,正常发送。但backup_local_save.diskqueue.000000.dat文件大小一直没有改变。 是我的配置文件有错误么? HOT 1
- logkit throws out error if redis_datatype is channel HOT 1
- go build failed HOT 1
- 如何指定ES的id HOT 3
- 找不到库 HOT 3
- go build fail
- 什么时候能支持下go mod
- 如何编译成下载页面中CentOS和Ubuntu不同的发行版? HOT 1
- Create SECURITY.md
- tailx模式无法读取文件
- github.com/qiniu/log 库 404 不存在
- 采集中断问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logkit.