# Automatically update index template in Logstash

**URL:** https://discuss.elastic.co/t/automatically-update-index-template-in-logstash/177923
**Category:** Logstash
**Created:** [April 23, 2019, 2:14am UTC](https://discuss.elastic.co/t/automatically-update-index-template-in-logstash/177923 "2019-04-23T02:14:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bbking](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bbking/32/77563_2.png) [@bbking](https://discuss.elastic.co/u/bbking)
#### Post date: [April 23, 2019, 2:14am UTC](https://discuss.elastic.co/t/automatically-update-index-template-in-logstash/177923/1 "2019-04-23T02:14:50Z")

</div>

Hello! I added new fields in an index template file and set `template_overwrite => true`, but Logstash didn't update the new template and shows mapping error. Is there a way to update an index template directly by Logstash?

Error:

```auto
[2019-04-22T19:01:57,545][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"success-2019", :_type=>"doc", :routing=>nil}, #<LogStash::Event:0x2b56411>], :response=>{"index"=>{"_index"=>"success-2019", "_type"=>"doc", "_id"=>"qHntR2oBp6bT1-SkpJwk", "status"=>400, "error"=>{"type"=>"strict_dynamic_mapping_exception", "reason"=>"mapping set to strict, dynamic introduction of [rollout] within [doc] is not allowed"}}}}

```

rollout is the new field I try to add and I used strict mapping in the index template.

pipeline.conf

```auto
input {
    beats {
        port => "5044"
    }
}

filter {
  ruby {
    path => "./parse_log.rb"
  }
}

output {
  stdout { codec => rubydebug }
  elasticsearch {
    template => "./success.json"
    template_name => "success"
    template_overwrite => "true"
    hosts => ["localhost:9200"]
    index => "success-%{+yyyy}"
  }
}

```

success.json

```auto
{
  "template": "success",
  "index_patterns": ["success-*"],
  "mappings": {
    "doc": {
      "dynamic": "strict",
      "properties": {
        "@timestamp" : {"type" : "date"},
        "@version" : {"type" : "keyword"},
        "source" : {"type" : "keyword"},
        "hash" : {"type" : "keyword"},
        "rollout": {"type": "boolean"}
      }
    }
  }
}

```

---

<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: [May 21, 2019, 2:15am UTC](https://discuss.elastic.co/t/automatically-update-index-template-in-logstash/177923/2 "2019-05-21T02:15:02Z")

</div>

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