You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pipeline/filters/nest.md
+74-50Lines changed: 74 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
1
# Nest
2
2
3
-
The _Nest Filter_ plugin allows you to operate on or with nested data. Its modes of operation are
3
+
The _Nest Filter_ plugin lets you operate on or with nested data. Its modes of operation are:
4
4
5
-
*`nest` - Take a set of records and place them in a map
6
-
*`lift` - Take a map by key and lift its records up
5
+
-`nest` - Take a set of records and place them in a map.
6
+
-`lift` - Take a map by key and lift its records up.
7
7
8
-
## Example usage \(nest\)
8
+
## Example usage for `nest`
9
9
10
-
As an example using JSON notation, to nest keys matching the `Wildcard` value `Key*` under a new key `NestKey` the transformation becomes,
10
+
As an example using JSON notation, to nest keys matching the `Wildcard` value `Key*`
11
+
under a new key `NestKey` the transformation becomes:
11
12
12
-
_Example \(input\)_
13
+
Input:
13
14
14
15
```text
15
16
{
@@ -19,7 +20,7 @@ _Example \(input\)_
19
20
}
20
21
```
21
22
22
-
_Example \(output\)_
23
+
Output:
23
24
24
25
```text
25
26
{
@@ -31,11 +32,12 @@ _Example \(output\)_
31
32
}
32
33
```
33
34
34
-
## Example usage \(lift\)
35
+
## Example usage for `lift`
35
36
36
-
As an example using JSON notation, to lift keys nested under the `Nested_under` value `NestKey*` the transformation becomes,
37
+
As an example using JSON notation, to lift keys nested under the `Nested_under` value
38
+
`NestKey*` the transformation becomes:
37
39
38
-
_Example \(input\)_
40
+
Input:
39
41
40
42
```text
41
43
{
@@ -47,7 +49,7 @@ _Example \(input\)_
47
49
}
48
50
```
49
51
50
-
_Example \(output\)_
52
+
Output:
51
53
52
54
```text
53
55
{
@@ -61,40 +63,47 @@ _Example \(output\)_
61
63
62
64
The plugin supports the following configuration parameters:
63
65
64
-
| Key | Value Format| Operation | Description |
66
+
| Key | Value format| Operation | Description |
65
67
| :--- | :--- | :--- | :--- |
66
-
| Operation | ENUM \[`nest` or `lift`\]|| Select the operation `nest` or `lift`|
67
-
| Wildcard | FIELD WILDCARD |`nest`| Nest records which field matches the wildcard |
68
-
|Nest\_under| FIELD STRING |`nest`| Nest records matching the `Wildcard` under this key |
69
-
|Nested\_under| FIELD STRING |`lift`| Lift records nested under the `Nested_under` key |
70
-
|Add\_prefix| FIELD STRING | ANY | Prefix affected keys with this string |
71
-
|Remove\_prefix| FIELD STRING | ANY | Remove prefix from affected keys if it matches this string |
68
+
|`Operation`| ENUM [`nest` or `lift`]|| Select the operation `nest` or `lift`|
69
+
|`Wildcard`| FIELD WILDCARD |`nest`| Nest records which field matches the wildcard |
70
+
|`Nest_under`| FIELD STRING |`nest`| Nest records matching the `Wildcard` under this key |
71
+
|`Nested_under`| FIELD STRING |`lift`| Lift records nested under the `Nested_under` key |
72
+
|`Add_prefix`| FIELD STRING | ANY | Prefix affected keys with this string |
73
+
|`Remove_prefix`| FIELD STRING | ANY | Remove prefix from affected keys if it matches this string |
72
74
73
75
## Getting Started
74
76
75
-
In order to start filtering records, you can run the filter from the command line or through the configuration file. The following invokes the [Memory Usage Input Plugin](../inputs/memory-metrics.md), which outputs the following \(example\),
77
+
To start filtering records, run the filter from the command line or through the
78
+
configuration file. The following example invokes the
79
+
[Memory Usage Input Plugin](../inputs/memory-metrics.md), which outputs the
> Note: Using the command line mode requires quotes parse the wildcard properly. The use of a configuration file is recommended.
90
+
Using command line mode requires quotes to parse the wildcard properly. The use
91
+
of a configuration file is recommended.
86
92
87
-
The following command will load the _mem_ plugin. Then the _nest_ filter will match the wildcard rule to the keys and nest the keys matching `Mem.*` under the new key `NEST`.
93
+
The following command loads the _mem_ plugin. Then the _nest_ filter matches the
94
+
wildcard rule to the keys and nests the keys matching `Mem.*` under the new key
This example nests all `Mem.*` and `Swap,*` items under the `Stats` key and then reverses these actions with a `lift` operation. The output appears unchanged.
159
+
This example nests all `Mem.*` and `Swap.*` items under the `Stats` key and then
160
+
reverses these actions with a `lift` operation. The output appears unchanged.
148
161
149
-
### Configuration File
162
+
### Example 2 Configuration File
150
163
151
164
{% tabs %}
152
165
{% tab title="fluent-bit.conf" %}
153
-
```python
166
+
167
+
```python copy
154
168
[INPUT]
155
169
Name mem
156
170
Tag mem.local
@@ -175,10 +189,11 @@ This example nests all `Mem.*` and `Swap,*` items under the `Stats` key and then
This example takes the keys starting with `Mem.*` and nests them under `LAYER1`, which itself is then nested under `LAYER2`, which is nested under `LAYER3`.
232
+
This example takes the keys starting with `Mem.*` and nests them under `LAYER1`,
233
+
which is then nested under `LAYER2`, which is nested under `LAYER3`.
217
234
218
-
### Configuration File
235
+
### Example 3 Configuration File
219
236
220
237
{% tabs %}
221
238
{% tab title="fluent-bit.conf" %}
222
-
```python
239
+
240
+
```python copy
223
241
[INPUT]
224
242
Name mem
225
243
Tag mem.local
@@ -249,10 +267,11 @@ This example takes the keys starting with `Mem.*` and nests them under `LAYER1`,
249
267
Wildcard LAYER2*
250
268
Nest_under LAYER3
251
269
```
252
-
{% endtab %}
253
270
271
+
{% endtab %}
254
272
{% tab title="fluent-bit.yaml" %}
255
-
```yaml
273
+
274
+
```yaml copy
256
275
pipeline:
257
276
inputs:
258
277
- name: mem
@@ -277,6 +296,7 @@ pipeline:
277
296
- name: stdout
278
297
match: '*'
279
298
```
299
+
280
300
{% endtab %}
281
301
{% endtabs %}
282
302
@@ -302,15 +322,19 @@ pipeline:
302
322
}
303
323
```
304
324
305
-
## Example \#4 - multiple nest and lift filters with prefix
325
+
## Example 4 - multiple nest and lift filters with prefix
306
326
307
-
This example starts with 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 is lifted.
327
+
This example uses the 3-level deep nesting of _Example 2_ and applies the
328
+
`lift`filter three times to reverse the operations. The end result is that all
329
+
records are at the top level, without nesting, again. One prefix is added for each
330
+
level that's lifted.
308
331
309
332
### Configuration file
310
333
311
334
{% tabs %}
312
335
{% tab title="fluent-bit.conf" %}
313
-
```python
336
+
337
+
```python copy
314
338
[INPUT]
315
339
Name mem
316
340
Tag mem.local
@@ -361,10 +385,12 @@ This example starts with the 3-level deep nesting of _Example 2_ and applies the
0 commit comments