iojancode / Serilog.Sinks.Dynatrace

Serilog Sink that sends log events to Dynatrace
11 stars 11 forks source link

OneAgent log automatic enrichment being prefixed #10

Open rafaelpadovezi opened 1 year ago

rafaelpadovezi commented 1 year ago

Hey, I'm trying to send logs to Dynatrace using this Sink and stumbled in this behavior. My OneAgent is configured to automatic enrich the app logs. The result is that the log event is showing in Dynatrace with the attr prefix to the field:

attr.dt.entity.process_group_instance: PROCESS_GROUP_INSTANCE-SOME_INSTANCE

This way Dynatrace is not relating the logs with the application. Could this property be a ROOT_PROPERTY? https://github.com/iojancode/Serilog.Sinks.Dynatrace/blob/69d22fdc38d612a710c47380d21764a07ca97945/DynatraceTextFormatter.cs#L14

Or maybe anything that starts with dt. should not have the prefix. Do you think it makes sense?

iojancode commented 1 year ago

Hi, you can avoid this behavior changing the default value for propertiesPrefix = "" at the Dynatrace method extension. Example:

var log = new LoggerConfiguration()
    .WriteTo.Dynatrace(
        accessToken: "xxx.yyyyyy.zzzzz",
        ingestUrl: "https://{your-environment-id}.live.dynatrace.com/api/v2/logs/ingest",
        propertiesPrefix: "")
    .CreateLogger();
rafaelpadovezi commented 1 year ago

Thanks @iojancode. I would like to add a prefix to the other properties but it's not required. I will follow this recommendation

iojancode commented 1 year ago

i will leave this one tagged as question for other users

weidingerhp commented 1 year ago

Added a PR that should make that work out of the box.