I am using the OpenTelemetry library in my .NET application to collect logs, which are sent to Grafana Alloy. Grafana Alloy then forwards these logs to Grafana Loki.
I need help mapping specific log attributes (e.g., service.name, environment, or other custom attributes) to Loki label filters. How can I configure Grafana Alloy to achieve this?
Any guidance or examples would be greatly appreciated. Thank you!
I only included two labels as examples (ConnectionId and Method), but you can add more. Just be sure to exercise caution and keep in mind the best practices on limiting potential values for labels.
Thank you for your guidance; I truly appreciate it. Could you please provide instructions on handling logs where the attributes are dynamic and not fixed?
I am pretty sure if a key doesn’t exist it would be assigned null value, which when sent to Loki would simply not exist as a label. I’d recommend you to test it out.
I don’t believe there is a way to dynamically do it. I haven’t had to do this, since it’s generally a bad idea because you do want to limit on number of labels and their potential values.