# Configure logstash with two same type sources

**URL:** https://discuss.elastic.co/t/configure-logstash-with-two-same-type-sources/108814
**Category:** Logstash
**Created:** [November 23, 2017, 2:58am UTC](https://discuss.elastic.co/t/configure-logstash-with-two-same-type-sources/108814 "2017-11-23T02:58:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hugo53](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hugo53/32/24588_2.png) [@hugo53](https://discuss.elastic.co/u/hugo53)
#### Post date: [November 23, 2017, 2:58am UTC](https://discuss.elastic.co/t/configure-logstash-with-two-same-type-sources/108814/1 "2017-11-23T02:58:36Z")

</div>

Hi there,  
I'm trying to configure logstash for my application, in the case:

- Two sources with same type 'raw' (it's a type of buynan-logstash, a nodejs module)

> ```
> input {
> tcp {
> type => "raw"
> port => 2101
> }
> tcp {
> type => "raw"
> port => 2102
> }
> }
> 
> ```

- I want to separate into two indices, like this:

> ```
> output {
> if [port] == 2101 {
> elasticsearch {
> index => "source1-%{+YYYY.MM.dd}"
> hosts => ["localhost:9200"]
> }
> }
> if [port] == 2102 {
> elasticsearch {
> index => "source2-%{+YYYY.MM.dd}"
> hosts => ["localhost:9200"]
> }
> }
> }
> 
> ```

However, it doesn't work. Only below works, although logs go into only one index:

```
  output {
         if [type] == 'raw' {
             elasticsearch {
                  index => "source12-%{+YYYY.MM.dd}"
                 hosts => ["localhost:9200"]
             }
         }
    }

```

Please help as I want to have two separated indices. Any recommendation would be appreciated!

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 23, 2017, 4:56am UTC](https://discuss.elastic.co/t/configure-logstash-with-two-same-type-sources/108814/2 "2017-11-23T04:56:51Z")

</div>

The `port` value is not carried through with the event, it's simply a configuration value. You should add it to the `type` value with `raw`.

---

<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: [December 21, 2017, 4:57am UTC](https://discuss.elastic.co/t/configure-logstash-with-two-same-type-sources/108814/3 "2017-12-21T04:57:01Z")

</div>

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