# Can't use type in logstash conf file

**URL:** <https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282>\
**Category:** Logstash\
**Created:** [April 5, 2017, 9:20am UTC](https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282 "2017-04-05T09:20:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikrams](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@vikrams](https://discuss.elastic.co/u/vikrams)\
**Post date:** [April 5, 2017, 9:20am UTC](https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282/1 "2017-04-05T09:20:01Z")

</div>

I am trying to use "type" for conditional filtering from two different inputs ,  
Below is a simplified configuration  
I dont get any data in my index using this file.  
But if i simply remove "type" and conditions using "type"  
everything works fine.

```
input {
    beats {
        port => "5043"
        #type => ABC
        type => "ABC"
    }
}

filter {
  if [type] == "ABC" {
        grok {
                match => {"message" => "%{TIMESTAMP_ISO8601} - \[%{NOTSPACE}\] %{LOGLEVEL} - %{JAVACLASS} \| %{WORD} %{URIPROTO}://%{URIHOST}/%{WORD:serviceName}-%{WORD}/%{WORD:entity}/%{BASE10NUM:id}, status = %{BASE10NUM:status}, time = %{BASE10NUM:duration} %{WORD:timeunits}."}
        }
        }
}
output {
    if [type] == "ABC" {
    elasticsearch {
        hosts => ["elastiSearchIp:9200"]
        index => "testlogs_1march"
    }
    }
}

```

Can some one please advice

Thankyou  
Vikram

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [April 5, 2017, 11:42am UTC](https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282/2 "2017-04-05T11:42:44Z")

</div>

This is standard practice.  
[https://www.elastic.co/guide/en/logstash/current/plugins-inputs-beats.html#plugins-inputs-beats-type](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-beats.html#plugins-inputs-beats-type)  
[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals)  
`type` when set is a field like any other. People use this patterns all the time.

try this, you should see the JSON'ed events in the console.

```auto
output {
  if [type] == "ABC" {
    stdout { codec => 'json'}
  } else {
    elasticsearch {
        hosts => ["elastiSearchIp:9200"]
        index => "testlogs_1march"
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![vikrams](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@vikrams](https://discuss.elastic.co/u/vikrams)\
**Post date:** [April 5, 2017, 6:27pm UTC](https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282/3 "2017-04-05T18:27:50Z")

</div>

Thanks @guyboertje

I found the problem .  
filebeat was already sending a type field in the message.  
And once set logstash cant override type feild.

Cheers  
Vikram

---

<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 3, 2017, 6:27pm UTC](https://discuss.elastic.co/t/cant-use-type-in-logstash-conf-file/81282/4 "2017-05-03T18:27:59Z")

</div>

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