-
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.
Open
Changes from 2 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,134 @@ | ||
# 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 | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
| Key | Description | Default | | ||
| :-- | :---------- | :------ | | ||
| `file` | The CSV file that Fluent Bit will use as a lookup table. The file should contain two columns (key and value), with the first row as an optional header that is skipped. Supports quoted fields and escaped quotes. | _none_ | | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `lookup_key` | The specific key in the input record to look up in the CSV file's first column. Supports [record accessor](../../administration/configuring-fluent-bit/record-accessor). | _none_ | | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `result_key` | The name of the key to add to the output record with the matched value from the CSV file's second column if a match is found. | _none_ | | ||
olegmukhin 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 following 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 has been set as the `lookup_key`) to find matching values in column 1 of the (`device-bu.csv`) CSV file. | ||
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 | ||
``` | ||
|
||
Where a match is found the filter adds new key (name of which is set by the `result_key` input) with the value from the second column of the CSV file of the matched row. | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
For above configuration the following output can be expected (when matching case is ignored as `ignore_case` is set to true): | ||
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", "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 | ||
|
||
The CSV is used to create an in-memory key value lookup table. Column 1 of the CSV is always used as key, while column 2 is assumed to be the value. All other columns in the CSV are ignored. | ||
|
||
This filter is intended for static datasets. CSV is loaded once when Fluent Bit starts and is not reloaded. | ||
|
||
Multiline values in CSV file are not currently supported. | ||
olegmukhin marked this conversation as resolved.
Show resolved
Hide resolved
|
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.