Add Parse JSON processor doc. (#3237)
* Add Parse JSON processor doc. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edit. Signed-off-by: carolxob <carolxob@amazon.com> * Formatted some information as a table instead of a list. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Removed smaller Parse JSON file. Signed-off-by: carolxob <carolxob@amazon.com> * Minor updates. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits to table. Signed-off-by: carolxob <carolxob@amazon.com> * Minor updates. Signed-off-by: carolxob <carolxob@amazon.com> * Minor update based on tech feedback. Signed-off-by: carolxob <carolxob@amazon.com> * Minor updates. Signed-off-by: carolxob <carolxob@amazon.com> * Modified 'indices' to 'indexes' Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edits. Signed-off-by: carolxob <carolxob@amazon.com> * Modified title. Signed-off-by: carolxob <carolxob@amazon.com> * Content edits from doc and editorial reviews. Signed-off-by: carolxob <carolxob@amazon.com> * Minor edit. Signed-off-by: carolxob <carolxob@amazon.com> * Updates. Signed-off-by: carolxob <carolxob@amazon.com> * Final review comments incorporated. Signed-off-by: carolxob <carolxob@amazon.com> --------- Signed-off-by: carolxob <carolxob@amazon.com>
This commit is contained in:
parent
662a16d9ca
commit
a246c60102
|
@ -1,27 +1,79 @@
|
|||
---
|
||||
layout: default
|
||||
title: Parse JSON
|
||||
title: parse_json
|
||||
parent: Processors
|
||||
grand_parent: Pipelines
|
||||
nav_order: 45
|
||||
---
|
||||
|
||||
# Parse JSON
|
||||
# parse_json
|
||||
|
||||
## Overview
|
||||
The `parse_json` processor parses JSON data for an event, including any nested fields. The processor extracts the JSON pointer data and adds the input event to the extracted fields.
|
||||
|
||||
The `parse_json` processor parses JSON data for an event, including any nested fields. The following table describes several optional parameters you can configure in the `parse_json` processor.
|
||||
|
||||
Option | Required | Type | Description
|
||||
:--- | :--- | :--- | :---
|
||||
source | No | String | The field in the `Event` that will be parsed. Default value is `message`.
|
||||
destination | No | String | The destination field of the parsed JSON. Defaults to the root of the `Event`. Cannot be `""`, `/`, or any whitespace-only `String` because these are not valid `Event` fields.
|
||||
pointer | No | String | A JSON Pointer to the field to be parsed. There is no `pointer` by default, meaning the entire `source` is parsed. The `pointer` can access JSON Array indices as well. If the JSON Pointer is invalid then the entire `source` data is parsed into the outgoing `Event`. If the pointed-to key already exists in the `Event` and the `destination` is the root, then the pointer uses the entire path of the key.
|
||||
## Configuration
|
||||
|
||||
<!---## Configuration
|
||||
You can configure the `parse_json` processor with the following options.
|
||||
|
||||
Content will be added to this section.
|
||||
| Option | Required | Type | Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `source` | No | String | The field in the `event` that will be parsed. Default value is `message`. |
|
||||
| `destination` | No | String | The destination field of the parsed JSON. Defaults to the root of the `event`. Cannot be `""`, `/`, or any whitespace-only `string` because these are not valid `event` fields. |
|
||||
| `pointer` | No | String | A JSON pointer to the field to be parsed. There is no `pointer` by default, meaning the entire `source` is parsed. The `pointer` can access JSON array indexes as well. If the JSON pointer is invalid then the entire `source` data is parsed into the outgoing `event`. If the key that is pointed to already exists in the `event` and the `destination` is the root, then the pointer uses the entire path of the key. |
|
||||
|
||||
## Metrics
|
||||
## Usage
|
||||
|
||||
Content will be added to this section.--->
|
||||
To get started, create the following `pipeline.yaml` file:
|
||||
|
||||
```yaml
|
||||
parse-json-pipeline:
|
||||
source:
|
||||
stdin:
|
||||
processor:
|
||||
- parse_json:
|
||||
sink:
|
||||
- stdout:
|
||||
```
|
||||
|
||||
### Basic example
|
||||
|
||||
To test the `parse_json` processor with the previous configuration, run the pipeline and paste the following line into your console, then enter `exit` on a new line:
|
||||
|
||||
```
|
||||
{"outer_key": {"inner_key": "inner_value"}}
|
||||
```
|
||||
{% include copy.html %}
|
||||
|
||||
The `parse_json` processor parses the message into the following format:
|
||||
|
||||
```
|
||||
{"message": {"outer_key": {"inner_key": "inner_value"}}", "outer_key":{"inner_key":"inner_value"}}}
|
||||
```
|
||||
|
||||
### Example with a JSON pointer
|
||||
|
||||
You can use a JSON pointer to parse a selection of the JSON data by specifying the `pointer` option in the configuration. To get started, create the following `pipeline.yaml` file:
|
||||
|
||||
```yaml
|
||||
parse-json-pipeline:
|
||||
source:
|
||||
stdin:
|
||||
processor:
|
||||
- parse_json:
|
||||
pointer: "outer_key/inner_key"
|
||||
sink:
|
||||
- stdout:
|
||||
```
|
||||
|
||||
To test the `parse_json` processor with the pointer option, run the pipeline, paste the following line into your console, and then enter `exit` on a new line:
|
||||
|
||||
```
|
||||
{"outer_key": {"inner_key": "inner_value"}}
|
||||
```
|
||||
{% include copy.html %}
|
||||
|
||||
The processor parses the message into the following format:
|
||||
|
||||
```
|
||||
{"message": {"outer_key": {"inner_key": "inner_value"}}", "inner_key": "inner_value"}
|
||||
```
|
Loading…
Reference in New Issue