> For the complete documentation index, see [llms.txt](https://docs.bindplane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bindplane.com/integrations/processors/slice-to-map.md).

# Slice to Map

Turns a slice (array) into a map keyed by a field from each element, so you can address entries by name instead of position. Optionally use another field as the value; otherwise the whole element becomes the value.

### Supported Telemetry Types

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

Choose Telemetry Type picks one signal per processor instance. Add another instance to handle a second signal.

### Configuration

#### Basic Configuration

<figure><img src="/files/MR6Lk5N5bNGzfys2Sk81" alt="Bindplane docs - Slice to Map - image 1"><figcaption></figcaption></figure>

**When to apply**

| Parameter             | Type               | Required | Default   | Description                                                                                                                    |
| --------------------- | ------------------ | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Choose Telemetry Type | Telemetry Selector | Yes      | Logs      | The signal this instance runs on: Logs, Metrics, or Traces (one at a time).                                                    |
| Condition             | OTTL Condition     | No       | *(empty)* | Convert only the records that match. A guard like `body["Event"]["EventData"]["Data"] != nil` skips records without the array. |

**Source and target fields**

| Parameter         | Type                                    | Required | Default   | Description                                                                                                                    |
| ----------------- | --------------------------------------- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Source Field Type | Enum: Resource, Attribute, Body, Custom | Yes      | Attribute | Where the source slice is read from. **Body is logs-only.** Custom takes any OTTL path.                                        |
| Source Field      | OTTL Field                              | Yes \*   | —         | The field holding the slice (array). Bracket notation for nested fields. For a Body source, leave empty to use the whole body. |
| Target Field Type | Enum: Resource, Attribute, Body, Custom | Yes      | Attribute | Where the resulting map is written. **Body is logs-only.**                                                                     |
| Target Field      | OTTL Field                              | Yes \*   | —         | Destination for the resulting map. For a Body target, leave empty to use the whole body.                                       |

\* The **Body** field type is the exception: it's optional, and leaving it empty targets the entire body.

**Body is available for Logs only.** For Metrics and Traces, the field type options are Resource, Attribute, and Custom.

**Key and value**

| Parameter   | Type   | Required | Default   | Description                                                                                                 |
| ----------- | ------ | -------- | --------- | ----------------------------------------------------------------------------------------------------------- |
| Key Field   | String | Yes      | —         | The field name *within each element* whose value becomes the map key. A field name, not an OTTL path.       |
| Value Field | String | No       | *(empty)* | The field name within each element to use as the value. Leave empty to keep the whole element as the value. |

### Examples

#### Reshape a Windows Event `Data` array into a name-keyed map

<figure><img src="/files/uuF7oM1wtugsUiQPJCxv" alt="Bindplane docs - Slice to Map - image 2"><figcaption></figcaption></figure>

### Configuration Tips

* Key Field and Value Field are field *names* inside each element, not OTTL paths.
* When two elements share the same key value, the later one overwrites the earlier in the resulting map.

### Troubleshooting

#### The result is empty or unchanged

Symptoms: the target isn't a name-keyed map after the processor runs.

Solutions:

1. Confirm the source field is actually a slice (array) and the Condition evaluates true.
2. Verify the Key Field name exists on the slice elements.

### Standalone Processor

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Processor
metadata:
  name: slice-to-map
spec:
  type: slice_to_map
  parameters:
    - name: telemetry_types
      value: Logs
    - name: log_condition
      value: body["Event"]["EventData"]["Data"] != nil
    - name: log_source_field_type
      value: Body
    - name: log_body_source_field
      value: Event["EventData"]["Data"]
    - name: log_target_field_type
      value: Body
    - name: log_body_target_field
      value: Event["EventData"]
    - name: log_key_field
      value: Name
    - name: log_value_field
      value: value
```

### Related Resources

* [SliceToMap — OTTL function reference](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs/README.md#slicetomap)

### Bindplane Resources

These XML and slice processors are designed to work together. Chain them to normalize, parse, and reshape XML end to end:

* [Convert XML Attributes To Elements](/integrations/processors/convert-xml-attributes-to-elements.md)
* [Convert XML Text To Elements](/integrations/processors/convert-xml-text-to-elements.md)
* [Insert XML Elements](/integrations/processors/insert-xml-elements.md)
* [Parse Simplified XML](/integrations/processors/parse-simplified-xml.md)
* [Get XML](/integrations/processors/get-xml.md)
* [Remove XML](/integrations/processors/remove-xml.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.bindplane.com/integrations/processors/slice-to-map.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
