pino-loki icon indicating copy to clipboard operation
pino-loki copied to clipboard

fix: force to string to satisfy loki api

Open chaintng opened this issue 6 months ago • 0 comments

image

Reproduce

Input any non string value in metadata key

logger.info({ meta: { statusCode: 200 } }, "Loki support only string in structured metadata")

Error

loghttp.PushRequest.Streams: []loghttp.LogProtoStream: unmarshalerDecoder: Value is string, but can't find closing '"' symbol, error found in #10 byte of ...|e":200}]]}]}|..., bigger context ...|ring in structured metadata",{"statusCode":200}]]}]}|...

Based on this document https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs

The JSON object must be a valid JSON object with string keys and string values. The JSON object should not contain any nested object. The JSON object must be set immediately after the log line.

I think it's better to transform to string for user instead of leave it error

chaintng avatar Sep 08 '25 19:09 chaintng