Structured logs with seriog, docker-loki-driver and loki

Hi,

I’m having the following setup:

  • A asp.net core application
  • serilog is used for logging
  • The asp.net app is running in docker
  • the docker-loki driver is used to forward the logs to loki

The log messages are forwarded correctly. But structured log properties are not forwarded properly:

_log.LogInformation(“Login attempt from {EMail} with {AppVersion}”, email, appVersion);

I would expect here that the fields email and appVersion are showing up in grafana loki as “detected Fields”. The logline appears, the email and appversion are inserted in the logmessage, but the fields are not detected.

Is there a config for enabling this?

Thanks

As long as your logs are in certain format you can parse them with LogQL. I am not familiar with what the automatic field detection does or doesn’t do, I generally try not to rely on it.

HI @tonyswumac,

sure, custom formatting and then parsing could be a solution, but I think it’s better to rely on the included features of grafana/loki.
Is anyone who successfully gets log properties from such a scenario into loki?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.