-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept multiple ingest pipelines in Filebeat (#8914)
Motivated by #8852 (comment). Starting with 6.5.0, Elasticsearch Ingest Pipelines have gained the ability to: - run sub-pipelines via the [`pipeline` processor](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/pipeline-processor.html), and - conditionally run processors via an [`if` field](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/ingest-processors.html). These abilities combined present the opportunity for a fileset to ingest the same _logical_ information presented in different formats, e.g. plaintext vs. json versions of the same log files. Imagine an entry point ingest pipeline that detects the format of a log entry and then conditionally delegates further processing of that log entry, depending on the format, to another pipeline. This PR allows filesets to specify one or more ingest pipelines via the `ingest_pipeline` property in their `manifest.yml`. If more than one ingest pipeline is specified, the first one is taken to be the entry point ingest pipeline. #### Example with multiple pipelines ```yaml ingest_pipeline: - pipeline-ze-boss.json - pipeline-plain.json - pipeline-json.json ``` #### Example with a single pipeline _This is just to show that the existing functionality will continue to work as-is._ ```yaml ingest_pipeline: pipeline.json ``` Now, if the root pipeline wants to delegate processing to another pipeline, it must use a `pipeline` processor to do so. This processor's `name` field will need to reference the other pipeline by its name. To ensure correct referencing, the `name` field must be specified as follows: ```json { "pipeline" : { "name": "{< IngestPipeline "pipeline-plain" >}" } } ``` This will ensure that the specified name gets correctly converted to the corresponding name in Elasticsearch, since Filebeat prefixes it's "raw" Ingest pipeline names with `filebeat-<version>-<module>-<fileset>-` when loading them into Elasticsearch.
- Loading branch information
1 parent
11a1917
commit 5ba1f11
Showing
17 changed files
with
479 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 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 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,8 @@ | ||
- module: foo | ||
# Fileset with multiple pipelines | ||
multi: | ||
enabled: true | ||
|
||
# Fileset with multiple pipelines with the last one being bad | ||
multibad: | ||
enabled: true |
This file contains 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,8 @@ | ||
type: log | ||
paths: | ||
- /tmp | ||
exclude_files: [".gz$"] | ||
|
||
fields: | ||
service.name: "foo" | ||
fields_under_root: true |
10 changes: 10 additions & 0 deletions
10
filebeat/_meta/test/module/foo/multi/ingest/json_logs.json
This file contains 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,10 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"rename": { | ||
"field": "json", | ||
"target_field": "log.meta" | ||
} | ||
} | ||
] | ||
} |
This file contains 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,27 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"grok": { | ||
"field": "message", | ||
"patterns": [ | ||
"^%{CHAR:first_char}" | ||
], | ||
"pattern_definitions": { | ||
"CHAR": "." | ||
} | ||
} | ||
}, | ||
{ | ||
"pipeline": { | ||
"if": "ctx.first_char == '{'", | ||
"name": "{< IngestPipeline "json_logs" >}" | ||
} | ||
}, | ||
{ | ||
"pipeline": { | ||
"if": "ctx.first_char != '{'", | ||
"name": "{< IngestPipeline "plain_logs" >}" | ||
} | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
filebeat/_meta/test/module/foo/multi/ingest/plain_logs.json
This file contains 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,12 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"grok": { | ||
"field": "message", | ||
"patterns": [ | ||
"^%{DATA:some_data}" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains 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,8 @@ | ||
module_version: 1.0 | ||
|
||
ingest_pipeline: | ||
- ingest/pipeline.json | ||
- ingest/json_logs.json | ||
- ingest/plain_logs.json | ||
|
||
input: config/multi.yml |
This file contains 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,8 @@ | ||
type: log | ||
paths: | ||
- /tmp | ||
exclude_files: [".gz$"] | ||
|
||
fields: | ||
service.name: "foo" | ||
fields_under_root: true |
10 changes: 10 additions & 0 deletions
10
filebeat/_meta/test/module/foo/multibad/ingest/json_logs.json
This file contains 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,10 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"rename": { | ||
"field": "json", | ||
"target_field": "log.meta" | ||
} | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
filebeat/_meta/test/module/foo/multibad/ingest/pipeline.json
This file contains 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,27 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"grok": { | ||
"field": "message", | ||
"patterns": [ | ||
"^%{CHAR:first_char}" | ||
], | ||
"pattern_definitions": { | ||
"CHAR": "." | ||
} | ||
} | ||
}, | ||
{ | ||
"pipeline": { | ||
"if": "ctx.first_char == '{'", | ||
"name": "{< IngestPipeline "json_logs" >}" | ||
} | ||
}, | ||
{ | ||
"pipeline": { | ||
"if": "ctx.first_char != '{'", | ||
"name": "{< IngestPipeline "plain_logs" >}" | ||
} | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
filebeat/_meta/test/module/foo/multibad/ingest/plain_logs_bad.json
This file contains 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,12 @@ | ||
{ | ||
"processors": [ | ||
{ | ||
"invalid_processor": { | ||
"field": "message", | ||
"patterns": [ | ||
"^%{DATA:some_data}" | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains 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,8 @@ | ||
module_version: 1.0 | ||
|
||
ingest_pipeline: | ||
- ingest/pipeline.json | ||
- ingest/json_logs.json | ||
- ingest/plain_logs_bad.json | ||
|
||
input: config/multi.yml |
Oops, something went wrong.