# Opensearch sink with index template makes dataprepper fails dataprepper to start

**URL:** <https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304>\
**Category:** Data Prepper\
**Created:** [February 3, 2025, 1:45pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304 "2025-02-03T13:45:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![piotrfrq](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@piotrfrq](https://forum.opensearch.org/u/piotrfrq)\
**Post date:** [February 3, 2025, 1:45pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304/1 "2025-02-03T13:45:26Z")

</div>

I have the latest Opensearch/Dataprepper (2.18).

This pipeline works fine without this directives  
template\_type: index-template  
template\_content: \>  
…

```auto
sink:
    - opensearch:
        hosts: [https://......]
        insecure: true
        username: "...."
        password: "....."
        index: syslog-standard
        dlq_file: "/usr/share/data-prepper/pipelines/dlq_syslog.err"
        template_type: index-template
        template_content: >
          {
            "template" : {
                  "mappings" : {
                          "properties": {
                                  "logsource": { "type" : "text" },
                                  "program": { "type" : "text" },
                                  "pid": { "type" : "text" },
                                  "timestampOriginalString": { "type" : "text" },
                                  "message": { "type" : "wildcard" }
                          }
                  }
            }
          }

```

But with them included I got errors in dataprepper logs:

```auto
2025-02-03T13:20:28,398 [syslog-pipeline-sink-worker-4-thread-1] WARN org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchSink - Failed to initialize OpenSearch sink, retrying: Forbidden access
2025-02-03T13:20:28,602 [syslog-pipeline-sink-worker-4-thread-1] INFO org.opensearch.dataprepper.pipeline.Pipeline - Pipeline [syslog-pipeline] - sink is not ready for execution, retrying
2025-02-03T13:20:28,603 [syslog-pipeline-sink-worker-4-thread-1] INFO org.opensearch.dataprepper.plugins.sink.opensearch.OpenSearchSink - Initializing OpenSearch sink
2025-02-03T13:20:28,603 [syslog-pipeline-sink-worker-4-thread-1] INFO org.opensearch.dataprepper.plugins.sink.opensearch.ConnectionConfiguration - Using the username provided in the config.
2025-02-03T13:20:28,603 [syslog-pipeline-sink-worker-4-thread-1] INFO org.opensearch.dataprepper.plugins.sink.opensearch.ConnectionConfiguration - Using the trust all strategy

```

Why?

**Update** : because of user permissions… The user I used (not admin) had enough rights to create index, but not for template creation. When I used admin user, it started to work.  
P.

---

<div class="post-metadata">

**Author:** ![kris](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kris/32/2208_2.png) [@kris](https://forum.opensearch.org/u/kris)\
**Post date:** [February 26, 2025, 6:38pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304/2 "2025-02-26T18:38:19Z")

</div>

@dlv - do you have any idea why this would require admin permissions? Is this a setting that can be adjusted? thanks

---

<div class="post-metadata">

**Author:** ![nateynate](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/nateynate/32/4913_2.png) [@nateynate](https://forum.opensearch.org/u/nateynate)\
**Post date:** [February 26, 2025, 8:00pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304/3 "2025-02-26T20:00:43Z")

</div>

> [@piotrfrq](#):
>
> **Update** : because of user permissions… The user I used (not admin) had enough rights to create index, but not for template creation. When I used admin user, it started to work.  
> P.

It makes sense. Out of the box (see screenie below) it looks like only admin has access to create an index template (`/index_template/put`). You may want to create a role that has the permission to do that and then assign your user to that role.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/7/72d7db023ccc6ac3a442908c687ad999646fa7e3.png)

---

<div class="post-metadata">

**Author:** ![dlv](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@dlv](https://forum.opensearch.org/u/dlv)\
**Post date:** [February 27, 2025, 2:12pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304/4 "2025-02-27T14:12:07Z")

</div>

@piotrfrq,

Yes, you will need permissions to put an index template as @nateynate suggested.

Alternatively, you can choose not to create the index template in Data Prepper.

We do not currently have a specific role with scoped down Data Prepper permissions. We have an open issue to support it, but haven’t made any specific work towards it.

> <https://github.com/opensearch-project/security/issues/3781>
>
> \*\*Is your feature request related to a problem?\*\*
> 
> Users of OpenSearch and Dat…a Prepper often have difficulty setting up the roles they use. Determining the permissions they need can be challenging.
> 
> \*\*What solution would you like?\*\*
> 
> To help users with these permissions, I'd like to provide useful predefined configurations in OpenSearch. In particular, I'm thinking of having existing OpenSearch roles tailored for Data Prepper. Users can choose to map the role or roles that fit their scenario to the user that they configure Data Prepper to use.
> 
> Here are the roles I'm thinking of creating:
> 
> \* \`data\_prepper\_write\` - Can write to any index along with other roles for writing
> \* \`data\_prepper\_observability\` - Similar to \`data\_prepper\_write\`, but can be scoped down to predefined indexes such as that for trace analytics and \[Simple Schema for Observability\](https://github.com/opensearch-project/opensearch-catalog/tree/main/docs/schema/observability). It would also need to be able to read from these indexes.
> \* \`data\_prepper\_read\` - A role that can read from any index to support the \`opensearch\` source.
> 
> \*\*What alternatives have you considered?\*\*
> 
> One alternative is a single role with all permissions. But, this seems too broad. We could encourage users to combine the roles they need for their specific use-case. Say, for example, have a user which maps to \`data\_prepper\_write\` and \`data\_prepper\_read\`.
> 
> \*\*Do you have any additional context?\*\*
> 
> We could create a PR for this, but I want to get feedback first.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [April 28, 2025, 2:12pm UTC](https://forum.opensearch.org/t/opensearch-sink-with-index-template-makes-dataprepper-fails-dataprepper-to-start/23304/5 "2025-04-28T14:12:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
