I’m using Grafana+Loki+OTLP.
I’m injecting data from a .NET application that produces structured logs. The resulting logs have their message format separate from the provided arguments.
E.g.:
{
"body": "The localization namespace '{Namespace}' was not found",
"severity": "Error",
"attributes": {
"Namespace": "Common"
},
"resources": {
"service.instance.id": "115812fc-9130-430e-af6d-4d7566a2750e",
"service.name": "BOM.Client",
"telemetry.sdk.language": "dotnet",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.8.1"
},
"instrumentation\_scope": {
"name": "Domain.Localization.Translator"
}
}
As you can see, the message body is The localization namespace '{Namespace}' was not found
. In a separate attributes field, you can see a key-value structure with the argument name and its value that is supposed to be placed into the body.
I’d want to format the message so that is like so: The localization namespace 'Common' was not found
.
Using LogQL {exporter="OTLP"} | json body="body", severity="severity", attributes="attributes", scope="instrumentation\_scope\[\\"name\\"\]" | label\_format service=job
and the Extract fields data transformation (plus some color mappings and so on), I was able to create a decent dashboard table:
Could I format the body to contain the attributes? I’m unsure what the correct terminology is for this in Grafana.
I appreciate any help you can provide.