Skip to content

[FEATURE] Add map_entries processor for array element projection #6611

@bagmarnikhil

Description

@bagmarnikhil

Is your feature request related to a problem? Please describe.

There is no way to convert between primitive arrays and object arrays. Processors like add_entries and delete_entries with iterate_on require List<Map<String, Object>> and cannot operate on primitive arrays (strings, numbers, booleans). Conversely, there
is no way to extract a single field from each object in an array into a flat primitive array.

For example, ["alpha", "beta"] cannot be transformed into [{"name": "alpha"}, {"name": "beta"}], and [{"url": "http://a1"}, {"url": "http://a2"}] cannot be reduced to ["http://a1", "http://a2"].

Describe the solution you'd like

A new map_entries processor that projects each element of an array through a key mapping. The direction is inferred from the input type:

  • Primitive array in → wraps each value into an object (e.g., "alpha" → {"name": "alpha"})
  • Object array in → extracts the specified field into a primitive (e.g., {"url": "http://a1"} → "http://a1")
Option Required Description
source Yes Key of the array to transform
target No Key to write the resulting array to. Defaults to source (in-place)
key Yes For primitive→object: the key name in the resulting object. For object→primitive: the key to extract
append_if_target_exists No When true, appends results to the existing target array instead of overwriting. Default false
map_entries_when No Expression evaluated against the root event. If false, the processor is skipped

Example: Primitive → Object

Input: {"names": ["alpha", "beta"]}

- map_entries:
    source: "/names"
    target: "/agents"
    key: "name"

Output: {"agents": [{"name": "alpha"}, {"name": "beta"}]}

Example: Object → Primitive (extract and merge)

Input: {"list_a": [{"url": "http://a1"}, {"url": "http://a2"}], "list_b": [{"url": "http://b1"}]}

- map_entries:
    source: "/list_a"
    target: "/all_urls"
    key: "url"
- map_entries:
    source: "/list_b"
    target: "/all_urls"
    key: "url"
    append_if_target_exists: true

Output: {"all_urls": ["http://a1", "http://a2", "http://b1"]}

Describe alternatives you've considered (Optional)

  • Using copy_values with from_list/to_list: This copies fields between lists of objects but produces a list of objects, not a flat primitive array. It also cannot handle the reverse direction (primitive → object).
  • Using add_entries with iterate_on: This requires the array to already be List<Map<String, Object>>. Passing a primitive array causes a ClassCastException at runtime. It also cannot extract fields into a flat array.
  • Separate processors for each direction: A single map_entries processor handles both directions naturally since the operation is the same (projection) — just inferred from the input type. Two separate processors would add unnecessary surface area.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Unplanned

Relationships

None yet

Development

No branches or pull requests

Issue actions