> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeycomb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Marshal

<Badge className="hny-badge-enterprise-addon" stroke>Ent+</Badge>

<Note>
  This feature is available as an add-on for the [Honeycomb Enterprise plan](https://www.honeycomb.io/pricing/).
  Please contact your Honeycomb account team for details.
</Note>

## Description

The Marshal Processor moves fields onto the body and turns them into a JSON or Key Value string.

<Note>
  To use this processor, the input body must not be a string; it must contain one or more fields.
</Note>

## Supported Types

| Metrics | Logs | Traces |
| ------- | ---- | ------ |
|         | ✓    |        |

## Configuration Table

|            Parameter           |    Type    |  Default |                                           Description                                          |
| :----------------------------: | :--------: | :------: | :--------------------------------------------------------------------------------------------: |
|             format             |    enum    |   None   |                      Which format to marshal to. Can be JSON, KV, or None.                     |
|    log\_fields\_to\_include    | ottlFields |    \[]   |                                  Which log fields to include.                                  |
|    log\_fields\_to\_exclude    | ottlFields |    \[]   |                                  Which log fields to exclude.                                  |
|         log\_selection         |    enum    |  Include |                 Whether to use include or exclude mode for log field selection.                |
|    body\_fields\_to\_include   | ottlFields |    \[]   |                                  Which body fields to include.                                 |
|    body\_fields\_to\_exclude   | ottlFields |    \[]   |                                  Which body fields to exclude.                                 |
|         body\_selection        |    enum    |  Exclude |                Whether to use include or exclude mode for body field selection.                |
| attribute\_fields\_to\_include | ottlFields |    \[]   |                               Which attribute fields to include.                               |
| attribute\_fields\_to\_exclude | ottlFields |    \[]   |                               Which attribute fields to exclude.                               |
|      attribute\_selection      |    enum    |  Exclude |              Whether to use include or exclude mode for attribute field selection.             |
|  resource\_fields\_to\_include | ottlFields |    \[]   |                                Which resource fields to include.                               |
|  resource\_fields\_to\_exclude | ottlFields |    \[]   |                                Which resource fields to exclude.                               |
|       resource\_selection      |    enum    |  Exclude |              Whether to use include or exclude mode for resource field selection.              |
|             flatten            |    bool    |   false  |                         Whether to flatten fields after moving to body.                        |
|           log\_field           |   string   |  bp.log  |    The name of the body field to move log fields into. If empty, moves fields to top level.    |
|        attribute\_field        |   string   | bp.attrs | The name of the body field to move attribute fields into. If empty, moves fields to top level. |
|         resource\_field        |   string   |  bp.res  |  The name of the body field to move resource fields into. If empty, moves fields to top level. |
|          kv\_delimiter         |   string   |     =    |                           The delimiter to use between key and value.                          |
|       kv\_pair\_delimiter      |   string   |          |                          The delimiter to use between key value pairs.                         |
|         sort\_by\_keys         |    bool    |   false  |                    Ensure deterministic ordering of keys before marshaling.                    |

### Basic Configuration

Below is an example of configuration using the defaults. It will select all body, attributes, and resource fields but will not flatten or marshal them.

Standalone Processor:

```yaml theme={}
apiVersion: bindplane.observiq.com/v1
kind: Processor
metadata:
  id: marshal-default
  name: marshal-default
spec:
  type: marshal
  parameters:
    - name: format
      value: None
    - name: log_fields_to_exclude
      value: []
    - name: log_fields_to_include
      value: []
    - name: log_selection
      value: Include
    - name: body_fields_to_exclude
      value: []
    - name: body_fields_to_include
      value: []
    - name: body_selection
      value: Exclude
    - name: attribute_fields_to_exclude
      value: []
    - name: attribute_fields_to_include
      value: []
    - name: attribute_selection
      value: Exclude
    - name: resource_fields_to_exclude
      value: []
    - name: resource_fields_to_include
      value: []
    - name: resource_selection
      value: Exclude
    - name: flatten
      value: false
    - name: log_field
      value: bp.log
    - name: attribute_field
      value: bp.attrs
    - name: resource_field
      value: bp.res
    - name: kv_delimiter
      value: =
    - name: kv_pair_delimiter
      value: ' '
    - name: sort_by_keys
      value: false
```

### Key Value Example

The configuration below will flatten and marshal the body into a string like this:

`name=test bp.log.severity_number=5 bp.attrs.baba=you bp.res.field1=val1 bp.res.field2=val2`

In the advanced section, the KV delimiters can be customized and the `bp.log`, `bp.attrs`, and `bp.res` fields can be renamed or ignored, putting fields directly onto the body.

Standalone Processor:

```yaml theme={}
apiVersion: bindplane.observiq.com/v1
kind: Processor
metadata:
  id: marshal-kv
  name: marshal-kv
spec:
  type: marshal
  parameters:
    - name: format
      value: KV
    - name: log_fields_to_exclude
      value: []
    - name: log_fields_to_include
      value:
        - severity_number
    - name: log_selection
      value: Include
    - name: body_fields_to_exclude
      value:
        - severity
    - name: body_fields_to_include
      value: []
    - name: body_selection
      value: Exclude
    - name: attribute_fields_to_exclude
      value:
        - host
    - name: attribute_fields_to_include
      value: []
    - name: attribute_selection
      value: Exclude
    - name: resource_fields_to_exclude
      value:
        - field2
        - field1
    - name: resource_fields_to_include
      value:
        - field1
        - field2
    - name: resource_selection
      value: Include
    - name: flatten
      value: true
    - name: log_field
      value: bp.log
    - name: attribute_field
      value: bp.attrs
    - name: resource_field
      value: bp.res
    - name: kv_delimiter
      value: =
    - name: kv_pair_delimiter
      value: ' '
    - name: sort_by_keys
      value: false
```
