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

[Feature Request] convertArrays should perform a shallow conversion instead of a deep conversion

Open anthonyma94 opened this issue 1 year ago • 2 comments

Loki's documentation is poor in this regard, but it actually supports arrays nested in an object:

logger.info(["hello", "world", 2]); // omitted
logger.info({ data: ["hello", "world", 2] }); // shows up

image

If the purpose of convertArrays is only to allow for ingest, I think it should only convert in cases where it would otherwise be omitted, i.e. top-level conversion. Currently it converts array in all levels:

image

anthonyma94 avatar Jul 12 '24 15:07 anthonyma94

Hey! Indeed, looks like a bug. Happy to accept a PR for the same Thankss

Julien-R44 avatar Jul 15 '24 04:07 Julien-R44

from the document, for structured metadata, it expect only string both key and value as stated here

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

You can optionally attach structured metadata to each log line by adding a JSON object to the end of the log line array. 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. Here is an example of a log entry with some structured metadata attached:

chaintng avatar Sep 08 '25 19:09 chaintng