elastic / ecs-dotnet

https://www.elastic.co/guide/en/ecs-logging/dotnet/current/setup.html
Apache License 2.0
114 stars 58 forks source link

ensure log jsonconverter can handle extra properties #318

Closed Mpdreamz closed 1 year ago

Mpdreamz commented 1 year ago

Ensures we don't fail on deserialising:

"log": {
  "logger":"root",
  "origin": {
    "file": {"line":90,"name":"main.py"},
    "function":"prepare_logging"
  }
}

Technically the ecs-json should be in the following format:

"log":{
   "logger":"root",
   "origin.file.line":90,
   "origin.file.name":"main.py"
   "origin.function":"prepare_logging"
}

This is also the format that beats will emit see e.g: https://github.com/elastic/beats/blob/e9272adcfcdd674b7a787ddd3a2416ad6f2c12be/libbeat/ecs/log.go#L48

Since this might be common enough this PR also adds support for deserializing the expanded form of log.

Mpdreamz commented 1 year ago

cc @flobernd somehow I can't assign you to review this?

flobernd commented 1 year ago

cc @flobernd somehow I can't assign you to review this?

Strange. I'll check it in a few minutes!