# Use Index templalte in logstash

**URL:** <https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865>\
**Category:** Logstash\
**Created:** [May 15, 2020, 6:11pm UTC](https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865 "2020-05-15T18:11:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hariskhalique](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@hariskhalique](https://discuss.elastic.co/u/hariskhalique)\
**Post date:** [May 15, 2020, 6:11pm UTC](https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865/1 "2020-05-15T18:11:21Z")

</div>

Hi,  
I have create a new index template. I want to reference my new template in logstash configuration. Following is my configuration file

```
input {
  jdbc {
    jdbc_driver_library => "/usr/share/java/mysql.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://172.31.15.138:3310/uwtinpewnf"
    jdbc_user => "appapi"
    jdbc_password => "asdfsASdf@3rf"
    jdbc_paging_enabled => true
    jdbc_page_size => 10000
    tracking_column => "pro_updated_at"
    use_column_value=>true
    # statement => "select * from `es_product_detail_info` where `pro_updated_date` >=:sql_last_value"
    schedule => "*/10 * * * *"
    statement => "select * from es_product_detail_parse where (UNIX_TIMESTAMP(`pro_updated_at`) >:sql_last_value and pro_updated_at < now()) ORDER BY pro_updated_at asc"

 }
}
output {
  elasticsearch {
    document_id=> "%{document_id}"
    # document_type => "doc"
    index => "products"
    doc_as_upsert => true
    hosts => ["http://localhost:9200"]
  }
  stdout{
    codec => rubydebug
  }
}

```

thanks

---

<div class="post-metadata">

**Author:** ![ptamba](https://avatars.discourse-cdn.com/v4/letter/p/7feea3/32.png) [@ptamba](https://discuss.elastic.co/u/ptamba)\
**Post date:** [May 16, 2020, 5:00am UTC](https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865/2 "2020-05-16T05:00:56Z")

</div>

there’s a template directive for [elasticsearch output](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template)

---

<div class="post-metadata">

**Author:** ![hariskhalique](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@hariskhalique](https://discuss.elastic.co/u/hariskhalique)\
**Post date:** [May 18, 2020, 4:28pm UTC](https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865/3 "2020-05-18T16:28:07Z")

</div>

I have found the way. You need to create template "prefix\*" in my case I create template with "pro\*". Using same logstash configuration it will create index using template.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 15, 2020, 4:28pm UTC](https://discuss.elastic.co/t/use-index-templalte-in-logstash/232865/4 "2020-06-15T16:28:08Z")

</div>

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