Configurable message and labels
Using pino-loki in projects like NestJS leads to not-so-friendly messages in Grafana. Please see example
Currently there's not way to configure pino-loki to make message look like this:
Sorry, my method does not work in a real app because pino is executed in a Worker. Need to find another solution.
Working solution implemented, please check
That fix looks great, would be interested in seeing this merged to master
Hate to piggy back on this. But would really love to see the better formatter as an option
Would love too. It seems that loki provide the third elements of values to be the log metadata =>
"values": [
[ "<unix epoch in nanoseconds>", "<log line>", {"trace_id": "0242ac120002", "user_id": "superUser123"}]
]
https://grafana.com/docs/loki/latest/reference/loki-http-api/#ingest-logs
Sorry for the late reply!
Have you considered formatting your logs directly in Grafana/LogQL?
{application="my-app"} | json | line_format "{{.msg}}"
This should give you the exact same result. You can even create a custom grafana dashboard with this default LogQL query, so you don't have to type it every time manually.
The solution proposed in #32 seems a bit "fragile" to me, because with Pino, it's possible to log without a msg, which will throw an error when the log is sent if used with PR #32. For example, consider the following log:
logger.info(['hello', 'world']) // Will throw an error since we don't have a `msg`
Reference: https://getpino.io/#/docs/api?id=logging-method-parameters
Happy to discuss about that feature if you guys have better ideas.
Closing since no answers. Feel free to re-open if needed