# Logstash forwarder with multiple log source types

**URL:** <https://discuss.elastic.co/t/logstash-forwarder-with-multiple-log-source-types/39801>\
**Category:** Logstash\
**Created:** [January 21, 2016, 4:50pm UTC](https://discuss.elastic.co/t/logstash-forwarder-with-multiple-log-source-types/39801 "2016-01-21T16:50:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirtdiver512](https://avatars.discourse-cdn.com/v4/letter/d/7ea924/32.png) [@dirtdiver512](https://discuss.elastic.co/u/dirtdiver512)\
**Post date:** [January 21, 2016, 4:50pm UTC](https://discuss.elastic.co/t/logstash-forwarder-with-multiple-log-source-types/39801/1 "2016-01-21T16:50:52Z")

</div>

All,

I have two log types I am trying to forward using the forwarder. One is a plain log and the other is a json fie. I need to be able to have ELK parse them differently but can not figure out how. For the json file, on the ELK server if i have the below it works great, but then the plain log file dies. the key t this working is the codec json part.

input {  
lumberjack {  
port =\> 5001  
ssl\_certificate =\> "/etc/pki/tls/certs/logstash-forwarder.crt"  
ssl\_key =\> "/etc/pki/tls/private/logstash-forwarder.key"  
codec =\> json  
}

---

<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:** [January 21, 2016, 6:25pm UTC](https://discuss.elastic.co/t/logstash-forwarder-with-multiple-log-source-types/39801/2 "2016-01-21T18:25:09Z")

</div>

You could use a json filter that you enable selectively if the event looks like a JSON object.

```auto
filter {
  if [message] =~ /^\{/ {
    json {
      source => "message"
    }
  }
}

```

---

<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:** [July 6, 2017, 5:14am UTC](https://discuss.elastic.co/t/logstash-forwarder-with-multiple-log-source-types/39801/3 "2017-07-06T05:14:54Z")

</div>


