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: administration/configuring-fluent-bit/classic-mode/record-accessor.md
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,25 @@
1
1
---
2
-
description: A full feature set to access content of your records
2
+
description: A full feature set to access content of your records.
3
3
---
4
4
5
-
# Record Accessor
5
+
# Record accessor
6
6
7
7
Fluent Bit works internally with structured records and it can be composed of an unlimited number of keys and values. Values can be anything like a number, string, array, or a map.
8
8
9
9
Having a way to select a specific part of the record is critical for certain core functionalities or plugins, this feature is called _Record Accessor._
10
10
11
-
> consider Record Accessor a simple grammar to specify record content and other miscellaneous values.
11
+
Consider record accessor to be a basic grammar to specify record content and other miscellaneous values.
12
12
13
13
## Format
14
14
15
-
A _record accessor_ rule starts with the character `$`. Using the structured content above as an example the following table describes how to access a record:
15
+
A record accessor rule starts with the character `$`. Use the structured content as an example. The following table describes how to access a record:
16
16
17
-
```javascript
17
+
```js
18
18
{
19
19
"log":"some message",
20
20
"stream":"stdout",
21
21
"labels": {
22
-
"color":"blue",
22
+
"color":"blue",
23
23
"unset":null,
24
24
"project": {
25
25
"env":"production"
@@ -28,23 +28,23 @@ A _record accessor_ rule starts with the character `$`. Using the structured con
28
28
}
29
29
```
30
30
31
-
The following table describe some accessing rules and the expected returned value:
31
+
The following table describes some accessing rules and the expected returned value:
32
32
33
33
| Format | Accessed Value |
34
34
| :--- | :--- |
35
-
| $log |"some message"|
36
-
| $labels\['color'\]|"blue"|
37
-
| $labels\['project'\]\['env'\]|"production"|
38
-
| $labels\['unset'\]| null |
39
-
| $labels\['undefined'\]||
35
+
|`$log`|`some message`|
36
+
|`$labels['color']`|`blue`|
37
+
|`$labels['project']['env']`|`production`|
38
+
|`$labels['unset']`|`null`|
39
+
|`$labels['undefined']`||
40
40
41
-
If the accessor key does not exist in the record like the last example `$labels['undefined']`, the operation is simply omitted, no exception will occur.
41
+
If the accessor key doesn't exist in the record like the last example `$labels['undefined']`, the operation is omitted, and no exception will occur.
42
42
43
-
## Usage Example
43
+
## Usage
44
44
45
-
The feature is enabled on a per plugin basis, not all plugins enable this feature. As an example consider a configuration that aims to filter records using [grep](../../../pipeline/filters/grep.md) that only matches where labels have a color blue:
45
+
The feature is enabled on a per plugin basis. Not all plugins enable this feature. As an example, consider a configuration that aims to filter records using [grep](../../../pipeline/filters/grep.md) that only matches where labels have a color blue:
46
46
47
-
```text
47
+
```yaml
48
48
[SERVICE]
49
49
flush 1
50
50
log_level info
@@ -68,17 +68,17 @@ The feature is enabled on a per plugin basis, not all plugins enable this featur
68
68
69
69
The file content to process in `test.log` is the following:
70
70
71
-
```javascript
71
+
```js
72
72
{"log":"message 1", "labels": {"color":"blue"}}
73
73
{"log":"message 2", "labels": {"color":"red"}}
74
74
{"log":"message 3", "labels": {"color":"green"}}
75
75
{"log":"message 4", "labels": {"color":"blue"}}
76
76
```
77
77
78
-
Running Fluent Bit with the configuration above the output will be:
78
+
When running Fluent Bit with the previous configuration, the output is:
The Fluent Bit record_accessor library has a limitation in the characters that can separate template variables- only dots and commas (`.` and `,`) can come after a template variable. This is because the templating library must parse the template and determine the end of a variable.
100
+
The Fluent Bit `record_accessor` library has a limitation in the characters that can separate template variables. Only dots and commas (`.` and `,`) can come after a template variable. This is because the templating library must parse the template and determine the end of a variable.
101
101
102
-
The following would be invalid templates because the two template variables are not separated by commas or dots:
102
+
The following templates are invalid because the template variables aren't separated by commas or dots:
103
103
104
104
-`$TaskID-$ECSContainerName`
105
105
-`$TaskID/$ECSContainerName`
106
106
-`$TaskID_$ECSContainerName`
107
107
-`$TaskIDfooo$ECSContainerName`
108
108
109
109
However, the following are valid:
110
+
110
111
-`$TaskID.$ECSContainerName`
111
112
-`$TaskID.ecs_resource.$ECSContainerName`
112
113
-`$TaskID.fooo.$ECSContainerName`
113
114
114
115
And the following are valid since they only contain one template variable with nothing after it:
0 commit comments