Formating loki log stream - err: loghttp.PushRequest.Streams

878 views Asked by At

I am trying to stream logs from a SaaS platform into loki. I get the below error loghttp.PushRequest.Streams: []*loghttp.Stream: loghttp.Stream.Labels: ReadString: expects " or n, but found {, error found in #10 byte of ...|","log": {"id":[469|..., bigger context ...|":[{ "stream": {"env": "XXXXX_logs","log": {"id":[4692850486,1470085],"flow_id":1470085,"pare|..

curl -v -i -u USER -H "X-Scope-OrgID: test-loki" -H "Content-Type: application/json" -XPOST -s "http://localhost:8088/loki/api/v1/push" --data-raw '{"streams":[{ "stream": {"env": "dev_logs","log": <ANOTHER HUGE JSON OBJECT HERE>}, "values": [ [ "1617704515000000000", "fizzbuzz"] ]}}]}'

My question is: does loki support nesting of Json inside streams like this? Any idea why this error might occur?

Thanks

1

There are 1 answers

0
jianping yin On

Maybe there's something wrong with your timestamp:1617704515000000000, if you use golang, you can try:

fmt.Sprint(time.Now().UnixNano())