# Marshal

### Description

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

{% hint style="info" %}
**NOTE**

To use this processor, the input body must not be a string; it must contain one or more fields.
{% endhint %}

### Supported Types

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

### Configuration Table

<table><thead><tr><th width="248.00390625">Parameter</th><th width="136.51171875">Type</th><th width="115.0625">Default</th><th width="358.5078125">Description</th></tr></thead><tbody><tr><td>format</td><td><code>enum</code></td><td><code>None</code></td><td>Which format to marshal to. Can be JSON, KV, or None.</td></tr><tr><td>log_fields_to_include</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which log fields to include.</td></tr><tr><td>log_fields_to_exclude</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which log fields to exclude.</td></tr><tr><td>log_selection</td><td><code>enum</code></td><td><code>Include</code></td><td>Whether to use include or exclude mode for log field selection.</td></tr><tr><td>body_fields_to_include</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which body fields to include.</td></tr><tr><td>body_fields_to_exclude</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which body fields to exclude.</td></tr><tr><td>body_selection</td><td><code>enum</code></td><td><code>Exclude</code></td><td>Whether to use include or exclude mode for body field selection.</td></tr><tr><td>attribute_fields_to_include</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which attribute fields to include.</td></tr><tr><td>attribute_fields_to_exclude</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which attribute fields to exclude.</td></tr><tr><td>attribute_selection</td><td><code>enum</code></td><td><code>Exclude</code></td><td>Whether to use include or exclude mode for attribute field selection.</td></tr><tr><td>resource_fields_to_include</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which resource fields to include.</td></tr><tr><td>resource_fields_to_exclude</td><td><code>ottlFields</code></td><td><code>[]</code></td><td>Which resource fields to exclude.</td></tr><tr><td>resource_selection</td><td><code>enum</code></td><td><code>Exclude</code></td><td>Whether to use include or exclude mode for resource field selection.</td></tr><tr><td>flatten</td><td><code>bool</code></td><td><code>false</code></td><td>Whether to flatten fields after moving to body.</td></tr><tr><td>log_field</td><td><code>string</code></td><td><code>bp.log</code></td><td>The name of the body field to move log fields into. If empty, moves fields to top level.</td></tr><tr><td>attribute_field</td><td><code>string</code></td><td><code>bp.attrs</code></td><td>The name of the body field to move attribute fields into. If empty, moves fields to top level.</td></tr><tr><td>resource_field</td><td><code>string</code></td><td><code>bp.res</code></td><td>The name of the body field to move resource fields into. If empty, moves fields to top level.</td></tr><tr><td>kv_delimiter</td><td><code>string</code></td><td><code>=</code></td><td>The delimiter to use between key and value.</td></tr><tr><td>kv_pair_delimiter</td><td><code>string</code></td><td></td><td>The delimiter to use between key value pairs.</td></tr><tr><td>sort_by_keys</td><td><code>bool</code></td><td><code>false</code></td><td>Ensure deterministic ordering of keys before marshaling.</td></tr></tbody></table>

#### 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.

**Web Interface**

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-8c83516fa4c38a19972f40b57148ff41e25ec2d7%2Fintegrations-processors-marshal-image-1.png?alt=media" alt="Bindplane docs - Marshal - image 1"><figcaption></figcaption></figure>

**Standalone Processor**

```yaml
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.

**Web Interface**

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-54ab21bafe8c3aaaca6cd661cb840216dc4e2780%2Fintegrations-processors-marshal-image-2.png?alt=media" alt="Bindplane docs - Marshal - image 2"><figcaption></figcaption></figure>

**Standalone Processor**

```yaml
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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/processors/marshal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
