Learning to Post logs to Loki

Hi

I’ve experimenting with Loki. I am planning to write a logger for Dart that publish to Loki.

Following this HTTP API | Grafana Labs and this example :

> $ curl -v -H "Content-Type: application/json" -XPOST -s "http://localhost:3100/loki/api/v1/push" --data-raw \
>   '{"streams": [{ "stream": { "foo": "bar2" }, "values": [ [ "1570818238000000000", "fizzbuzz" ] ] }]}'
> 

I get this response :

curl -v -H “Content-Type: application/json” -XPOST -s “http://localhost:3100/loki/api/v1/push” -->data-raw ‘{“streams”: [{ “stream”: { “foo”: “bar2” }, “values”: [ [ “1570818238000000000000”, >“fizzbuzz” ] ] }]}’

  • Trying ::1:3100…
  • Connected to localhost (::1) port 3100 (#0)
    POST /loki/api/v1/push HTTP/1.1
    Host: localhost:3100

User-Agent: curl/7.74.0
Accept: /
Content-Type: application/json
Content-Length: 102

  • upload completely sent off: 102 out of 102 bytes
  • Mark bundle as not supporting multiuse
    < HTTP/1.1 400 Bad Request
    < Content-Type: text/plain; charset=utf-8
    < X-Content-Type-Options: nosniff
    < Date: Sun, 27 Feb 2022 14:31:15 GMT
    < Content-Length: 274
    <
    loghttp.PushRequest.Streams: *loghttp.Stream: unmarshalerDecoder: Value looks like > Number/Boolean/None, but can’t find its end: ‘,’ or ‘}’ symbol, error found in #10 byte of …|uzz" ] ] > }]}|…, bigger context …|s": [ [ “1570818238000000000000”, “fizzbuzz” ] ] }]}|…
  • Connection #0 to host localhost left intact

Something obvious goes wrong.
Anyone who can help?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.