logstash-plugins / logstash-input-beats

Apache License 2.0
86 stars 81 forks source link

Fixed to populate the metadata fields even if the source's value is nil #502

Closed edmocosta closed 1 month ago

edmocosta commented 1 month ago

Fixed to populate the @metadata fields even if the source's metadata value is nil. An example that generate this condition is using the Lumberjack output as source data.

How to test this PR locally?

Please have a look at the Steps to reproduce section of this issue , it has clear instructions on how to simulate the problem locally.


Closes: https://github.com/logstash-plugins/logstash-input-beats/issues/497

andsel commented 1 month ago

Tested and the downstream pipeline outputs events like:

{
    "@timestamp" => 2024-08-28T08:03:37.338247Z,
     "@metadata" => {
        "input" => {
            "beats" => {
                "host" => {
                    "ip" => "0:0:0:0:0:0:0:1"
                }
            }
        }
    },
      "@version" => "1",
         "event" => {
        "original" => "2024-08-28T08:03:36.707308Z {name=andreas-MBP-2.station} test"
    },
       "message" => "2024-08-28T08:03:36.707308Z {name=andreas-MBP-2.station} test",
          "tags" => [
        [0] "beats_input_codec_plain_applied"
    ]
}