Describe the bug
When a log message is submitted to the /loki/api/v1/push endpoint, and is encoded as JSON, its structured metadata is not recorded correctly.
To Reproduce
Steps to reproduce the behavior:
- Started Loki (SHA or version): v3.1.1
- Sent JSON record to `/loki/api/v1/push``:
{
"streams": [
{
"stream": {"service_name":"test"},
"values": [["1723985681658755744", "{}", {"message": "a\nb\nc"}]]
}
]
}
Command:
curl -H 'Content-Type: application/json' -d '{"streams": [{"stream": {"service_name":"test"},"values":[["1723986725000000000", "{}", {"message": "a\nb\nc"}]]}]}' -v 'http://127.0.0.1:3100/loki/api/v1/push'
- Sent query:
{"service_name":"test"}
Command:
curl -v 'http://127.0.0.1:3100/loki/api/v1/query_range?query=%7Bservice_name%3D%22test%22%7D&start=1723986725000000000' | jq .data.result
- Observe the resulting labels:
{"service_name": "test", "message": "a\\nb\\nc"}. Note that the message is different from the one submitted.
Expected behavior
The result should have the labels {"service_name": "test", "message": "a\nb\nc"}
Environment:
- Infrastructure: bare-metal
- Deployment tool:
/bin/bash
Screenshots, Promtail config, or terminal output
localhost ~ # curl -H 'Content-Type: application/json' -d '{"streams": [{"stream": {"service_name":"test"}, "values":[["1723986725000000000", "{}", {"message": "a\nb\nc"}]]}]}' 'http://127.0.0.1:3100/loki/api/v1/push'
localhost ~ # curl -s 'http://127.0.0.1:3100/loki/api/v1/query_range?query=%7Bservice_name%3D%22test%22%7D&start=1723986725000000000' | jq -c .data.result
[{"stream":{"message":"a\\nb\\nc","service_name":"test"},"values":[["1723986725000000000","{}"]]}]
Describe the bug
When a log message is submitted to the
/loki/api/v1/pushendpoint, and is encoded as JSON, its structured metadata is not recorded correctly.To Reproduce
Steps to reproduce the behavior:
Command:
{"service_name":"test"}Command:
{"service_name": "test", "message": "a\\nb\\nc"}. Note that themessageis different from the one submitted.Expected behavior
The result should have the labels
{"service_name": "test", "message": "a\nb\nc"}Environment:
/bin/bashScreenshots, Promtail config, or terminal output