Unexpected "=" in label set

Hello everyone!

I’m trying to write Opentelemetry logs to Loki pushing them from my dotnet service directly to Loki with Opentelemetry packages, but ran into a problem. When I’m trying to get logs in grafana I get an error

could not write JSON response: 1:2: parse error: unexpected "=" in label set, expected identifier or "}"

After researching I realized that the problem was only with some of the log entries.
Service have a metrics endpoint for prometheus. And when Prometheus collects metrics, the service writes a log entry like this:

RequestPath:/api/metrics RequestId:8000886a-0002-f400-b63f-84710c7967bb Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/2 GET https://service/api/metrics - 200 - application/openmetrics-text;+version=1.0.0;+charset=utf-8 7.6416ms

I assume that loki use string “application/openmetrics-text;+version=1.0.0;+charset=utf-8” as common label and falling when I’m trying to get logs.

Does loki have some settings to do with this case? This label creates automatically by Opentelemetry package, so I don’t know what to do with it. I can disable Microsoft.AspNetCore.Hosting.Diagnostics logs but I think I need to resolve this issue on loki side or on the Otel package side.

Loki, but itself, doesn’t parse or inject labels. All labels come from your app. I don’t use opentelemetry in .net, so I can’t tell you exactly what to do, but you should be able to configure it accordingly and remove labels that you do not want.

Yes, this is one of the options. I’m not sure I can do this in code without using some middleware like Otel Collector, but of course that’s not a question to loki and I check for this possibility in Otel package.

I’m asking here, because Loki support Otel logs, and this is default behavior of official Openetelemtry packages. I didn’t add any custom labels. So it’s looking strange that loki falls here.