Skip to content

Add new "copy" operationΒ #90

@consulthys

Description

@consulthys

The mutate filter provides support for performing a host of different operations on a Logstash event fields, yet it is not easy to copy all fields of a sub-structure at the root level. For instance, 3rd-party systems sometimes produce events such as the following one:

{
     "bla": "bla",
     "meh": "meh",
     "payload" : {
          "foo" : "1224",
          "bar" : "woohoo",
          "baz" : 0,
          "timestamp" : 1449356706000
     }
}

And what you really want is to have the payload fields at the root level and potentially discard all root level fields, like this:

{
     "foo" : "1224",
     "bar" : "woohoo",
     "baz" : 0,
     "timestamp" : 1449356706000
}

In order to support this, one could use a ruby filter, but it'd be nice if the mutate filter could support this "copy" operation out-of-the-box, too. I've picked copy but potential alternate names could be extract, reify, move, promote.

The configuration of this new feature would look like this:

filter {
   mutate {
      copy => {
         "field" => "payload"
         "empty_root" => true
      }
   }
}

where:

  • field would denote the event field (must be a Hash) whose content shall be copied at the root level (can also be a sprintf-style field)
  • if empty_root is true, all root-level fields would also be deleted in the process (defaults to false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions