These docs are for Cribl Stream 4.0 and are no longer actively maintained.
See the latest version (4.11).
JSON Unroll
The JSON Unroll Function accepts a JSON object string _raw
field, unrolls/explodes an array of objects therein into individual events, while also inheriting top level fields. See example(s). Cribl highly recommends not using this JSON Unroll function for certain types of data. Instead, perform the unrolling using an event breaker for those inputs which support configuring an event breaker. Specifying the event breaker type JSON Array and toggling the JSON Extract Fields option to Yes will accomplish the same unrolling but much more efficiently. This is recommended, for example, for CloudTrail and Office635 events, which are collected as JSON arrays.
Usage
Filter: Filter expression (JS) that selects data to feed through the Function. Defaults to true
, meaning it evaluates all events.
Description: Simple description about this Function. Defaults to empty.
Final: If toggled to Yes
, stops feeding data to the downstream Functions. Defaults to No
.
Path: Path to array to unroll, e.g., foo.0.bar
.
New name: The name that the exploded array element will receive in each new event. Leave empty to expand the array element with its original name.
Example(s)
Assume you have an incoming event that has a _raw
field as a JSON object string like this:
{"date":"9/25/18 9:10:13.000 PM",
"name":"Amrit",
"age":42,
"allCars": [
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },
{ "name":"GM", "models":[ "Trans AM", "Oldsmobile", "Cadillac" ] },
{ "name":"Fiat", "models":[ "500", "Panda" ] },
{ "name":"Blackberry", "models":[ "KEY2", "Bold Touch 9900" ] }
]
}
Settings:
Path: allCars
New Name: cars
Output Events:
Event 1:
{"_raw":"{"date":"9/25/18 9:10:13.000 PM","name":"Amrit","age":42,"cars":{"name":"Ford","models":["Fiesta","Focus","Mustang"]}}"}
Event 2:
{"_raw":"{"date":"9/25/18 9:10:13.000 PM","name":"Amrit","age":42,"cars":{"name":"GM","models":["Trans AM","Oldsmobile","Cadillac"]}}"}
Event 3:
{"_raw":"{"date":"9/25/18 9:10:13.000 PM","name":"Amrit","age":42,"cars":{"name":"Fiat","models":["500","Panda"]}}"}
Event 4:
{"_raw":"{"date":"9/25/18 9:10:13.000 PM","name":"Amrit","age":42,"cars":{"name":"Blackberry","models":["KEY2","Bold Touch 9900"]}}"}
Each element under the original allCars array is now placed in a cars field in its own event, inheriting original top level fields; date, name and age