-
Notifications
You must be signed in to change notification settings - Fork 531
pipeline: filters: lookup added new filter page #1953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
olegmukhin
wants to merge
21
commits into
fluent:master
Choose a base branch
from
olegmukhin:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−0
Open
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b9cc326
pipeline: filters: lookup added new filter
olegmukhin 6fb3490
SUMMARY: add link to new page
alexakreizinger 805c619
Update pipeline/filters/lookup.md
olegmukhin ed65192
Update pipeline/filters/lookup.md
olegmukhin 1e14ae8
Update pipeline/filters/lookup.md
olegmukhin 6cb38bb
Update pipeline/filters/lookup.md
olegmukhin 0c3163b
Update pipeline/filters/lookup.md
olegmukhin fcfe916
Update pipeline/filters/lookup.md
olegmukhin 90e78ef
Update pipeline/filters/lookup.md
olegmukhin 47163ae
Update pipeline/filters/lookup.md
olegmukhin 0f5b54b
Update pipeline/filters/lookup.md
olegmukhin 82adfa1
Update pipeline/filters/lookup.md
alexakreizinger 131f1be
Apply suggestions from code review
alexakreizinger 58deea0
Update pipeline/filters/lookup.md
olegmukhin 15241a3
Update pipeline/filters/lookup.md
olegmukhin d5b3822
Update pipeline/filters/lookup.md
olegmukhin 40389b3
Update pipeline/filters/lookup.md
olegmukhin 06f0c2d
Update pipeline/filters/lookup.md
olegmukhin 72c4a79
Update pipeline/filters/lookup.md
olegmukhin 8a2f563
Update pipeline/filters/lookup.md
olegmukhin 7232996
Update pipeline/filters/lookup.md
olegmukhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# Lookup | ||
|
||
The Lookup plugin looks up a key value from a record in a specified CSV file and, if a match is found, adds the corresponding value from the CSV as a new key-value pair to the record. | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Configuration parameters | ||
|
||
The plugin supports the following configuration parameters: | ||
|
||
| Key | Description | Default | | ||
| :-- | :---------- | :------ | | ||
| `file` | The CSV file that the Lookup filter will use as a lookup table. This file must contain one column of keys and one column of values. The Lookup filter treats the first row as a header and ignores it. Supported quoted fields and escaped quotes. | _none_ | | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `lookup_key` | Specifies the key to search for in the CSV file's first column. Supports [record accessor](../administration/configuring-fluent-bit/classic-mode/record-accessor) syntax. | _none_ | | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `result_key` | If `lookup_key` is found, sets the name of the new key to add to the output record. This new key uses the corresponding value from the second column of the CSV file in the same row where `lookup_key` was found. | _none_ | | ||
alexakreizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `ignore_case` | Ignore case when matching the lookup key against the CSV keys. | `false` | | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Example configuration | ||
|
||
{% tabs %} | ||
{% tab title="fluent-bit.yaml" %} | ||
|
||
```yaml | ||
parsers: | ||
- name: json | ||
format: json | ||
|
||
pipeline: | ||
inputs: | ||
- name: tail | ||
tag: test | ||
path: devices.log | ||
read_from_head: true | ||
parser: json | ||
|
||
filters: | ||
- name: lookup | ||
match: test | ||
file: device-bu.csv | ||
lookup_key: $hostname | ||
result_key: business_line | ||
ignore_case: true | ||
|
||
outputs: | ||
- name: stdout | ||
match: test | ||
``` | ||
|
||
{% endtab %} | ||
{% tab title="fluent-bit.conf" %} | ||
|
||
```text | ||
[PARSER] | ||
Name json | ||
Format json | ||
|
||
[INPUT] | ||
Name tail | ||
Tag test | ||
Path devices.log | ||
Read_from_head On | ||
Parser json | ||
|
||
[FILTER] | ||
Name lookup | ||
Match test | ||
File device-bu.csv | ||
Lookup_key $hostname | ||
Result_key business_line | ||
Ignore_case On | ||
|
||
[OUTPUT] | ||
Name stdout | ||
Match test | ||
``` | ||
|
||
{% endtab %} | ||
{% endtabs %} | ||
|
||
The previous configuration reads log records from `devices.log` that includes the following values for device hostnames: | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```text | ||
alexakreizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"hostname": "server-prod-001"} | ||
{"hostname": "Server-Prod-001"} | ||
{"hostname": "db-test-abc"} | ||
{"hostname": 123} | ||
{"hostname": true} | ||
{"hostname": " host with space "} | ||
{"hostname": "quoted \"host\""} | ||
{"hostname": "unknown-host"} | ||
{} | ||
{"hostname": [1,2,3]} | ||
{"hostname": {"sub": "val"}} | ||
{"hostname": " "} | ||
``` | ||
|
||
It uses the value of the `hostname` field (which was set as the `lookup_key`) to find matching values in the first column of `device-bu.csv`. | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```text | ||
hostname,business_line | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
server-prod-001,Finance | ||
db-test-abc,Engineering | ||
db-test-abc,Marketing | ||
web-frontend-xyz,Marketing | ||
app-backend-123,Operations | ||
"legacy-system true","Legacy IT" | ||
" host with space ","Infrastructure" | ||
"quoted ""host""", "R&D" | ||
no-match-host,Should Not Appear | ||
``` | ||
|
||
When the filter finds a match, it adds a new key with the name specified by `result_key` and a value from the second column of the CSV file of the row where `lookup_key` was found. | ||
|
||
This results in output that resembles the following: | ||
|
||
```text | ||
alexakreizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"hostname"=>"server-prod-001", "business_line"=>"Finance"} | ||
{"hostname"=>"Server-Prod-001", "business_line"=>"Finance"} | ||
{"hostname"=>"db-test-abc", "business_line"=>"Marketing"} | ||
{"hostname"=>123} | ||
{"hostname"=>true} | ||
{"hostname"=>" host with space ", "business_line"=>"Infrastructure"} | ||
{"hostname"=>"quoted "host"", "business_line"=>"R&D"} | ||
{"hostname"=>"unknown-host"} | ||
{} | ||
{"hostname"=>[1, 2, 3]} | ||
{"hostname"=>{"sub"=>"val"}} | ||
``` | ||
|
||
## CSV import | ||
|
||
|
||
Fluent Bit creates an in-memory key/value lookup table from the CSV file that you provide. The first column of this CSV is always treated as a key, and its second column as a value. Any other columns are ignored. | ||
|
||
This filter is intended for static datasets. After Fluent Bit loads the CSV file, it won't reload that file, which means the filter's lookup table won't update to reflect any changes. | ||
|
||
This filter doesn't support multiline values in CSV files. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.