Closed mailtosmyk closed 4 years ago
The error should be better, the label field is incorrect. See https://github.com/grafana/loki/blob/master/docs/api.md#examples-8
Also I recommend you to use the v1 API see the link above.
I can take a look at this!
Sure I'll feed you with more info on how to on Monday!
Hi, Iv encoured the same error using the following json, im using the new api : loki/api/v1/push
{"streams": [{ "labels": "{foo=\"bar\"}", "entries": [{ "ts": "2018-12-18T08:28:06.801064-04:00", "line": "fizzbuzz" }] }]}
The error is : parse error at line 1, col 2: syntax error: unexpected }, expecting IDENTIFIER
I’m sorry you’re encountering this again, the v1 api has a different label format.
See https://github.com/grafana/loki/blob/master/docs/api.md#examples-4
Basically now it’s a map before it was a string.
@talham7391 It's happening here: https://github.com/grafana/loki/blob/master/pkg/distributor/validator.go#L60
I would change add more context to the error. Something like
return httpgrpc.Errorf(http.StatusBadRequest, fmt.Errorf("error parsing labels: %v", err.Error()))
Okay great, will push a PR soon!
Describe the bug When trying to submit stream thru api endpoint "/api/prom/push" loki return error code 400 with not helpful message "parse error at line 1, col 1: syntax error: unexpected IDENTIFIER"
To Reproduce 1 clone grafana/loki from https://github.com/grafana/loki 2 Run docker-compose up 3 Using chrome plugin ARC create POST request with based on documentation from https://github.com/grafana/loki/blob/v1.3.0/docs/api.md#get-lokiapiv1labels:
CURL output: c:\test\loki\production\loki-mixin>curl -H "Content-Type: application/json" -X POST "http://localhost:3100/api/prom/push" -d "{\"streams\": [{ \"labels\": \"cats\", \"entries\": [{ \"ts\": \"2018-12-18T08:28:06.801064-04:00\", \"line\": \"fizzbuzz\" }] }]}" parse error at line 1, col 1: syntax error: unexpected IDENTIFIER
4 Loki server return "parse error at line 1, col 1: syntax error: unexpected IDENTIFIER"
Expected behavior HTTP status code 2XX or better explanation what is missing/incorrect
Environment: