copy_values

The copy_values processor copies values within an event and is a mutate event processor.

Configuration

You can configure the copy_values processor with the following options.

OptionRequiredDescription
entriesYesA list of entries to be copied in an event.
from_keyYesThe key of the entry to be copied.
to_keyYesThe key of the new entry to be added.
overwrite_if_key_existsNoWhen set to true, the existing value is overwritten if key already exists in the event. The default value is false.

Usage

To get started, create the following pipeline.yaml file:

  1. pipeline:
  2. source:
  3. ...
  4. ....
  5. processor:
  6. - copy_values:
  7. entries:
  8. - from_key: "message"
  9. to_key: "newMessage"
  10. overwrite_if_to_key_exists: true
  11. sink:

copy

Next, create a log file named logs_json.log and replace the path in the file source of your pipeline.yaml file with that filepath. For more information, see Configuring Data Prepper.

For example, before you run the copy_values processor, if the logs_json.log file contains the following event record:

  1. {"message": "hello"}

When you run this processor, it parses the message into the following output:

  1. {"message": "hello", "newMessage": "hello"}

If newMessage already exists, its existing value is overwritten with value.

copy_values - 图1