Nest
The Nest filter plugin lets you operate on or with nested data. Its modes of operation are:
nest: Take a set of records and place them in a map.liftTake a map by key and lift its records up.
Example usage for nest
nestAs an example using JSON notation, to nest keys matching the Wildcard value Key* under a new key NestKey the transformation becomes:
Input:
{
"Key1" : "Value1",
"Key2" : "Value2",
"OtherKey" : "Value3"
}Output:
{
"OtherKey" : "Value3"
"NestKey" : {
"Key1" : "Value1",
"Key2" : "Value2",
}
}Example usage for lift
liftAs an example using JSON notation, to lift keys nested under the Nested_under value NestKey* the transformation becomes:
Input:
Output:
Configuration parameters
The plugin supports the following configuration parameters:
Operation
Enum [nest or lift]
Select the operation nest or lift
Wildcard
Field wildcard
nest
Nest records which field matches the wildcard
Nest_under
Field string
nest
Nest records matching the Wildcard under this key
Nested_under
Field string
lift
Lift records nested under the Nested_under key
Add_prefix
Field string
Any
Prefix affected keys with this string
Remove_prefix
Field string
Any
Remove prefix from affected keys if it matches this string
Get started
To start filtering records, run the filter from the command line or through the configuration file. The following example invokes the Memory Usage input plugin, which outputs the following:
Example 1 - nest
Use nest from the command line
nest from the command lineUsing the command line mode requires quotes to parse the wildcard properly. The use of a configuration file is recommended.
The following command loads the mem plugin. Then the nest filter matches the wildcard rule to the keys and nests the keys matching Mem.* under the new key NEST.
Nest configuration file
Nest result
The output of both the command line and configuration invocations should be identical and result in the following output.
Example 2 - nest and lift undo
nest and lift undoThis example nests all Mem.* and Swap.* items under the Stats key and then reverses these actions with a lift operation. The output appears unchanged.
nest and lift undo configuration file
nest and lift undo configuration filenest and lift undo result
nest and lift undo resultExample 3 - nest 3 levels deep
nest 3 levels deepThis example takes the keys starting with Mem.* and nests them under LAYER1, which is then nested under LAYER2, which is nested under LAYER3.
Deep nest configuration file
nest configuration fileDeep nest result
nest resultExample 4 - multiple nest and lift filters with prefix
nest and lift filters with prefixThis example uses the 3-level deep nesting of Example 2 and applies the lift filter three times to reverse the operations. The end result is that all records are at the top level, without nesting, again. One prefix is added for each level that's lifted.
nest and lift prefix configuration file
nest and lift prefix configuration filenest and lift prefix result
nest and lift prefix resultLast updated
Was this helpful?