I am using open telemetry with loki service (and grafana to display the logs). The body of the log contains placeholders, and under "attributes" you can see the fields. Is there any way to also display the log with the values replaced? i.e.:
{
"body": "End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}",
"attributes": {
"ElapsedMilliseconds": 489.8766,
"StatusCode": 200
}
}
I'd like to have something like:
{
"enrichedBody": "End processing HTTP request after 489.8766ms - 200",
"body": "End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}",
"attributes": {
"ElapsedMilliseconds": 489.8766,
"StatusCode": 200
}
}
We are using auto instrumentation with .NET Core, so there is no code in the application. I've setup open telemetry with loki, and grafana to display it. I've tried different processors (batch, using attributes and resources...) but no luck so far.
Any idea? Thanks!
The described behavior is expected. You can force an exporter to do what you expect by setting
OTEL_DOTNET_AUTO_LOGS_INCLUDE_FORMATTED_MESSAGEref: https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/v1.4.0/docs/config.md#logs-exporter.Under the hood, this environmental variable sets this property https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.7.0/docs/logs/customizing-the-sdk/README.md?plain=1#L27-L31