# Error with manage\_template on multiple elasticsearch outputs

**URL:** <https://discuss.elastic.co/t/error-with-manage-template-on-multiple-elasticsearch-outputs/220435>\
**Category:** Logstash\
**Created:** [February 21, 2020, 6:17pm UTC](https://discuss.elastic.co/t/error-with-manage-template-on-multiple-elasticsearch-outputs/220435 "2020-02-21T18:17:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmccoy](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tmccoy](https://discuss.elastic.co/u/tmccoy)\
**Post date:** [February 21, 2020, 6:17pm UTC](https://discuss.elastic.co/t/error-with-manage-template-on-multiple-elasticsearch-outputs/220435/1 "2020-02-21T18:17:19Z")

</div>

Hi, thanks in advance for your assistance!

**Description:**  
I have an output configuration where I am using an if statement to select an output to elasticsearch, essentially I want to index documents into an index depending on the contents of the event-type field, as well as have logstash manage the templates and ILM. I have two indexes/templates auth and other.

Here's an example configuration of what I am trying to do:

> output {  
> if [event\_type] == "auth" {  
> elasticsearch {  
> hosts =\> ["[http://example-host:9200](http://example-host:9200)"]  
> user =\> "test-user"  
> password =\> "test-password"  
> template\_name =\> "auth"  
> manage\_template =\> true  
> template =\> "/etc/logstash/mappings/auth.json"  
> template\_overwrite =\> true  
> doc\_as\_upsert =\> true  
> document\_id =\> "%{id}"  
> ilm\_enabled =\> true  
> ilm\_rollover\_alias =\> "auth-events"  
> ilm\_policy =\> "auth\_ilm\_policy"  
> }  
> }  
> else {  
> elasticsearch {  
> hosts =\> ["[http://example-host:9200](http://example-host:9200)"]  
> user =\> "test-user"  
> password =\> "test-password"  
> template\_name =\> "other"  
> manage\_template =\> true  
> template =\> "/etc/logstash/mappings/other.json"  
> template\_overwrite =\> true  
> doc\_as\_upsert =\> true  
> document\_id =\> "%{id}"  
> ilm\_enabled =\> true  
> ilm\_rollover\_alias =\> "other"  
> ilm\_policy =\> "other\_ilm\_policy"  
> }  
> }  
> }

**Logstash version:** 7.0.1 (also tested on 7.6.0 getting the same error)

**Error:**

> [2020-02-20T23:42:38,354][ERROR][logstash.outputs.elasticsearch] Failed to install template. {:message=\>"undefined method `update' for nil:NilClass", :class=>"NoMethodError", :backtrace=>["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.0.2-java/lib/logstash/outputs/elasticsearch/template_manager.rb:39:in `add\_ilm\_settings\_to\_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.0.2-java/lib/logstash/outputs/elasticsearch/template\_manager.rb:14:in `install_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:129:in `install\_template'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.0.2-java/lib/logstash/outputs/elasticsearch/common.rb:50:in `block in setup\_after\_successful\_connection'"]}

The first output (auth) works fine, the template and ILM are managed properly. The second output (other) the template is not managed and ILM is not setup properly as well.

---

<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:** [March 20, 2020, 6:17pm UTC](https://discuss.elastic.co/t/error-with-manage-template-on-multiple-elasticsearch-outputs/220435/2 "2020-03-20T18:17:23Z")

</div>

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