# Distinguish between syslog inputs

**URL:** <https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877>\
**Category:** Logstash\
**Created:** [April 27, 2017, 2:11pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877 "2017-04-27T14:11:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kernelpanic](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kernelpanic](https://discuss.elastic.co/u/kernelpanic)\
**Post date:** [April 27, 2017, 2:11pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/1 "2017-04-27T14:11:55Z")

</div>

Hello, can anyone tell me how I would distinguish between two different syslog sources in Logstash, for example one source being a firewall device and another being an ESXi host? I know you can use tags but as I can't install anything at the source then I can't place tags on the message before they're sent to Logstash.

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)\
**Post date:** [April 27, 2017, 2:31pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/2 "2017-04-27T14:31:33Z")

</div>

Hi,

There are a couple of ways you can do that.

1. Have a separate Logstash input for each source (different ports) and tag/add fields on each source respectively.
2. Filter based on the "host" field that should be available and contain the originating IP/hostname, if you know them beforehand.

More options could be available depending on the setup, but those above should be the most straightforward.

---

<div class="post-metadata">

**Author:** ![kernelpanic](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kernelpanic](https://discuss.elastic.co/u/kernelpanic)\
**Post date:** [April 27, 2017, 3:20pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/3 "2017-04-27T15:20:41Z")

</div>

Thankyou, I'll try filtering on the host / IP address field.

---

<div class="post-metadata">

**Author:** ![kernelpanic](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kernelpanic](https://discuss.elastic.co/u/kernelpanic)\
**Post date:** [April 27, 2017, 3:52pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/4 "2017-04-27T15:52:15Z")

</div>

Hello again, I did try to add the syslog configuration to my logstash.conf but instead of accepting syslog messages it threw the Windows event logs I was also collecting into the syslog index. Can anyone tell me where I've gone wrong? My configuration is below:

```
input {
  beats {
    port => 5044
  }
}

output {
  elasticsearch {
    hosts => ["192.168.56.226:9200", "192.168.52.251:9200", "192.168.52.252:9200"]
    manage_template => false
    index => "%{[@metadata][beat]}-%{+YYYY.MM}"
    document_type => "%{[@metadata][type]}"
  }
}
#########################################################################################
#########################################################################################
input {
  tcp {
    port => 5000
    type => syslog
  }
  udp {
    port => 5000
    type => syslog
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => ["received_at", "%{@timestamp}"]
      add_field => ["received_from", "%{host}"]
    }
    date {
      match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
    }
  }
}

output {
  elasticsearch {
       hosts => ["192.168.56.226:9200", "192.168.52.251:9200", "192.168.52.252:9200"]
    index =>["syslog-%{+YYYY.MM}"]
  }
}
```

---

<div class="post-metadata">

**Author:** ![kernelpanic](https://avatars.discourse-cdn.com/v4/letter/k/c89c15/32.png) [@kernelpanic](https://discuss.elastic.co/u/kernelpanic)\
**Post date:** [April 27, 2017, 4:35pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/5 "2017-04-27T16:35:04Z")

</div>

I think I've sorted it with the following config:

```
input {
  beats {
    port => 5044
    type => wineventlog
  }
  tcp {
    port => 5000
    type => syslog
  }
  udp {
    port => 5000
    type => syslog
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
      add_field => ["received_at", "%{@timestamp}"]
      add_field => ["received_from", "%{host}"]
    }
    date {
      match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
    }
  }
}

output {
  if [type] == "wineventlog" {
   elasticsearch {
     hosts => ["192.168.56.226:9200", "192.168.52.251:9200", "192.168.52.252:9200"]
     manage_template => false
     index => "%{[@metadata][beat]}-%{+YYYY.MM}"
     document_type => "%{[@metadata][type]}"
 }
}

  if [type] == "syslog" {
   elasticsearch {
    hosts => ["192.168.56.226:9200", "192.168.52.251:9200", "192.168.52.252:9200"]
    index => ["syslog-%{+YYYY.MM}"]
   }
  }
 }
```

---

<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 25, 2017, 4:46pm UTC](https://discuss.elastic.co/t/distinguish-between-syslog-inputs/83877/6 "2017-05-25T16:46:21Z")

</div>

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