Skip to content

Latest commit

 

History

History
116 lines (98 loc) · 3.05 KB

flatten.md

File metadata and controls

116 lines (98 loc) · 3.05 KB

flatten operator

The flatten operator flattens a field by moving its children up to the same level as the field. The operator only flattens a single level deep.

Configuration Fields

Field Default Description
id flatten A unique identifier for the operator
output Next in pipeline The connected operator(s) that will receive all outbound entries
field required The field to be flattened.
on_error send The behavior of the operator if it encounters an error. See on_error
if An expression that, when set, will be evaluated to determine whether this operator should be used for the given entry. This allows you to do easy conditional parsing without branching logic with routers.

Example usage:


Flatten an object to the base of the record

- type: flatten
  field: key1
Input Entry Output Entry
{
  "resource": { },
  "labels": { },  
  "record": {
    "key1": {
      "nested1": "nestedval1",
      "nested2": "nestedval2"
    },
    "key2": "val2"
  }
}
  {
    "resource": { },
    "labels": { },  
    "record": {
      "nested1": "nestedval1",
      "nested2": "nestedval2",
      "key2": "val2"
    }
  }

Flatten an object within another object

- type: flatten
  field: wrapper.key1
Input Entry Output Entry
{
  "resource": { },
  "labels": { },  
  "record": {
    "wrapper": {
      "key1": {
        "nested1": "nestedval1",
        "nested2": "nestedval2"
      },
      "key2": "val2"
    }
  }
}
{
  "resource": { },
  "labels": { },  
  "record": {
    "wrapper": {
      "nested1": "nestedval1",
      "nested2": "nestedval2",
      "key2": "val2"
    }
  }
}