generated from amazon-archives/__template_Apache-2.0
-
Couldn't load subscription status.
- Fork 621
[DOC] Add fail processor documentation #5980
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a9b3a7c
Add fail processor documentation
vagimeli aa14064
Merge branch 'main' into fail-processor
vagimeli 3def449
Merge branch 'main' into fail-processor
vagimeli 48d01e8
Merge branch 'main' into fail-processor
vagimeli 50825ba
Update fail.md
vagimeli 5aac822
Address tech review feedback and add SME's code examples
vagimeli 6d034e5
Merge branch 'main' into fail-processor
vagimeli 4b3ca83
Merge branch 'main' into fail-processor
vagimeli 385d587
Address tech review comments
vagimeli cd636ae
Update _ingest-pipelines/processors/fail.md
vagimeli 6736e66
Update _ingest-pipelines/processors/fail.md
vagimeli f581ea2
Update _ingest-pipelines/processors/fail.md
vagimeli 9b7119c
Merge branch 'main' into fail-processor
vagimeli 6cbc5bf
Merge branch 'main' into fail-processor
vagimeli 3ea73b5
Update _ingest-pipelines/processors/fail.md
vagimeli 95ecf12
Update _ingest-pipelines/processors/fail.md
vagimeli 27aef26
Update _ingest-pipelines/processors/fail.md
vagimeli ec15cfb
Update fail.md
vagimeli 999551e
Merge branch 'main' into fail-processor
vagimeli 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| --- | ||
| layout: default | ||
| title: Fail | ||
| parent: Ingest processors | ||
| nav_order: 100 | ||
| --- | ||
|
|
||
| # Fail processor | ||
|
|
||
| The `fail` processor is useful for performing data transformation and enrichment during the indexing process. The primary use case for the `fail` processor is to fail an indexing operation when certain conditions are met. | ||
|
|
||
| The following is the syntax for the `fail` processor: | ||
|
|
||
| ```json | ||
| "fail": { | ||
| "if": "ctx.foo == 'bar'", | ||
| "message": "Custom error message" | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ## Configuration parameters | ||
|
|
||
| The following table lists the required and optional parameters for the `fail` processor. | ||
|
|
||
| Parameter | Required/Optional | Description | | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| |-----------|-----------|-----------| | ||
| `message` | Required | A custom error message to be included in the failure response. | ||
| `description` | Optional | A brief description of the processor. | | ||
| `if` | Optional | A condition for running the processor. | | ||
| `ignore_failure` | Optional | Specifies whether the processor continues execution even if it encounters an error. If set to `true`, then failures are ignored. Default is `false`. | | ||
| `on_failure` | Optional | A list of processors to run if the processor fails. | | ||
| `tag` | Optional | An identifier tag for the processor. Useful for debugging in order to distinguish between processors of the same type. | | ||
|
|
||
| ## Using the processor | ||
|
|
||
| Follow these steps to use the processor in a pipeline. | ||
|
|
||
| ### Step 1: Create a pipeline | ||
|
|
||
| The following query creates a pipeline, named `fail-log-pipeline`, that uses the `fail` processor to intentionally fail the pipeline execution for log events: | ||
|
|
||
| ```json | ||
| PUT _ingest/pipeline/fail-log-pipeline | ||
| { | ||
| "description": "A pipeline to test the fail processor for log events", | ||
| "processors": [ | ||
| { | ||
| "fail": { | ||
| "if": "ctx.user_info.contains('password') || ctx.user_info.contains('credit card')", | ||
| "message": "Document containing personally identifiable information (PII) cannot be indexed!" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ### Step 2 (Optional): Test the pipeline | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| It is recommended that you test your pipeline before you ingest documents. | ||
| {: .tip} | ||
|
|
||
| To test the pipeline, run the following query: | ||
|
|
||
| ```json | ||
| POST _ingest/pipeline/fail-log-pipeline/_simulate | ||
| { | ||
| "docs": [ | ||
| { | ||
| "_source": { | ||
| "user_info": "Sensitive information including credit card" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Response | ||
|
|
||
| The following example response confirms that the pipeline is working as expected: | ||
|
|
||
| ```json | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "docs": [ | ||
| { | ||
| "error": { | ||
| "root_cause": [ | ||
| { | ||
| "type": "fail_processor_exception", | ||
| "reason": "Document containing personally identifiable information (PII) cannot be indexed!" | ||
| } | ||
| ], | ||
| "type": "fail_processor_exception", | ||
| "reason": "Document containing personally identifiable information (PII) cannot be indexed!" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ### Step 3: Ingest a document | ||
|
|
||
| The following query ingests a document into an index named `testindex1`: | ||
|
|
||
| ```json | ||
| PUT testindex1/_doc/1?pipeline=fail-log-pipeline | ||
| { | ||
| "user_info": "Sensitive information including credit card" | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Response | ||
|
|
||
| The request fails to index the log event into the index `testindex1` due to the string `credit card` being present in `user_info`. The following response includes the custom error message specified in the fail processor: | ||
|
|
||
| ```json | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| "error": { | ||
| "root_cause": [ | ||
| { | ||
| "type": "fail_processor_exception", | ||
| "reason": "Document containing personally identifiable information (PII) cannot be indexed!" | ||
| } | ||
| ], | ||
| "type": "fail_processor_exception", | ||
| "reason": "Document containing personally identifiable information (PII) cannot be indexed!" | ||
| }, | ||
| "status": 500 | ||
| } | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| ### Step 4 (Optional): Retrieve the document | ||
|
|
||
| Because the log event was not indexed due to the pipeline failure, attempting to retrieve it results in the document not found error `"found": false`: | ||
|
|
||
| ```json | ||
| GET testindex1/_doc/1 | ||
| ``` | ||
| {% include copy-curl.html %} | ||
|
|
||
| #### Document error example | ||
|
|
||
| ```json | ||
vagimeli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "_index": "testindex1", | ||
| "_id": "1", | ||
| "found": false | ||
| } | ||
| ``` | ||
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.