Skip to content

Commit 9fe4552

Browse files
authored
Merge pull request #1656 from fluent/lynettemiles/sc-135602/update-fluent-bit-fluent-bit-docs-administration
2 parents 6f4b988 + 7770717 commit 9fe4552

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

administration/configuring-fluent-bit/classic-mode/record-accessor.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
2-
description: A full feature set to access content of your records
2+
description: A full feature set to access content of your records.
33
---
44

5-
# Record Accessor
5+
# Record accessor
66

77
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.
88

99
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._
1010

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.
1212

1313
## Format
1414

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:
1616

17-
```javascript
17+
```js
1818
{
1919
"log": "some message",
2020
"stream": "stdout",
2121
"labels": {
22-
"color": "blue",
22+
"color": "blue",
2323
"unset": null,
2424
"project": {
2525
"env": "production"
@@ -28,23 +28,23 @@ A _record accessor_ rule starts with the character `$`. Using the structured con
2828
}
2929
```
3030

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:
3232

3333
| Format | Accessed Value |
3434
| :--- | :--- |
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']` | |
4040

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.
4242

43-
## Usage Example
43+
## Usage
4444

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:
4646

47-
```text
47+
```yaml
4848
[SERVICE]
4949
flush 1
5050
log_level info
@@ -68,17 +68,17 @@ The feature is enabled on a per plugin basis, not all plugins enable this featur
6868

6969
The file content to process in `test.log` is the following:
7070

71-
```javascript
71+
```js
7272
{"log": "message 1", "labels": {"color": "blue"}}
7373
{"log": "message 2", "labels": {"color": "red"}}
7474
{"log": "message 3", "labels": {"color": "green"}}
7575
{"log": "message 4", "labels": {"color": "blue"}}
7676
```
7777

78-
Running Fluent Bit with the configuration above the output will be:
78+
When running Fluent Bit with the previous configuration, the output is:
7979

8080
```text
81-
$ bin/fluent-bit -c fluent-bit.conf
81+
$ bin/fluent-bit -c fluent-bit.conf
8282
Fluent Bit v1.x.x
8383
* Copyright (C) 2019-2020 The Fluent Bit Authors
8484
* Copyright (C) 2015-2018 Treasure Data
@@ -95,23 +95,25 @@ Fluent Bit v1.x.x
9595
{"date":1599862267.483692,"log":"message 4","labels":{"color":"blue"}}
9696
```
9797

98-
### Limitations of record_accessor templating
98+
### Limitations of `record_accessor` templating
9999

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.
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.
101101

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:
103103

104104
- `$TaskID-$ECSContainerName`
105105
- `$TaskID/$ECSContainerName`
106106
- `$TaskID_$ECSContainerName`
107107
- `$TaskIDfooo$ECSContainerName`
108108

109109
However, the following are valid:
110+
110111
- `$TaskID.$ECSContainerName`
111112
- `$TaskID.ecs_resource.$ECSContainerName`
112113
- `$TaskID.fooo.$ECSContainerName`
113114

114115
And the following are valid since they only contain one template variable with nothing after it:
116+
115117
- `fooo$TaskID`
116118
- `fooo____$TaskID`
117119
- `fooo/bar$TaskID`

0 commit comments

Comments
 (0)