# Send data to 2 elasticsearch indexes

**URL:** https://discuss.elastic.co/t/send-data-to-2-elasticsearch-indexes/133324
**Category:** Logstash
**Created:** [May 25, 2018, 1:06pm UTC](https://discuss.elastic.co/t/send-data-to-2-elasticsearch-indexes/133324 "2018-05-25T13:06:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sana](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sana](https://discuss.elastic.co/u/sana)
#### Post date: [May 25, 2018, 1:06pm UTC](https://discuss.elastic.co/t/send-data-to-2-elasticsearch-indexes/133324/1 "2018-05-25T13:06:49Z")

</div>

i'm using logstash to send data from 2 different input:files and elastic search:  
input {  
elasticsearch{  
hosts =\> "http://server\_name:9200"  
type =\> "host1"  
}  
file{  
path =\> "/home/sana/pfe/docker/logs/\*\*/\*.log"  
type =\> "host2" }}

now i want to put each data in diffrent index in my local elasticsearch using this method:  
if "host1" in [type]{  
elasticsearch{ hosts =\> ["localhost:9200"]  
index =\> ["integrationlogs"] }  
}  
if "host2" in [type]{  
elasticsearch{ hosts =\> ["localhost:9200"]  
index =\> ["locallogs"] }  
}

please what is the correct way to handle this

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [May 25, 2018, 1:40pm UTC](https://discuss.elastic.co/t/send-data-to-2-elasticsearch-indexes/133324/2 "2018-05-25T13:40:27Z")

</div>

What you have should work.

---

<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 22, 2018, 1:50pm UTC](https://discuss.elastic.co/t/send-data-to-2-elasticsearch-indexes/133324/3 "2018-06-22T13:50:44Z")

</div>

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