# Filtering rules in Logstash

**URL:** <https://discuss.elastic.co/t/filtering-rules-in-logstash/86463>\
**Category:** Logstash\
**Created:** [May 19, 2017, 4:10pm UTC](https://discuss.elastic.co/t/filtering-rules-in-logstash/86463 "2017-05-19T16:10:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvindsing](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@arvindsing](https://discuss.elastic.co/u/arvindsing)\
**Post date:** [May 19, 2017, 4:10pm UTC](https://discuss.elastic.co/t/filtering-rules-in-logstash/86463/1 "2017-05-19T16:10:09Z")

</div>

I have configured few filebeats machines and they all are sending logs ( whatever configured). For instance I have applied filtering for /var/log/auth.log. Now I am getting too much of data. I want to record only this type of logs ad then send it to Kibana " **Failed password for root from 61.177.172.69 port 20080 ssh2**"

Here are 3 files that I am using now:-

02-beats-input.conf

input {  
beats {  
port =\> 5044  
ssl =\> false  
ssl\_certificate =\> "/etc/pki/tls/certs/logstash-forwarder.crt"  
ssl\_key =\> "/etc/pki/tls/private/logstash-forwarder.key"  
}  
}  
output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
manage\_template =\> false  
}  
}

10-syslog-filter.conf  
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}"]  
}  
syslog\_pri { }  
date {  
match =\> ["syslog\_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]  
}  
}  
}

30-elasticsearch-output.conf  
output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
sniffing =\> true  
manage\_template =\> false  
index =\> "%{[@metadata][beat]}-%{+YYYY.MM.dd}"  
document\_type =\> "%{[@metadata][type]}"  
}  
}

Can someone please point what all filter I can apply over here....

---

<div class="post-metadata">

**Author:** ![Bhargav\_Narine](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bhargav\_Narine](https://discuss.elastic.co/u/Bhargav_Narine)\
**Post date:** [May 20, 2017, 6:54pm UTC](https://discuss.elastic.co/t/filtering-rules-in-logstash/86463/2 "2017-05-20T18:54:19Z")

</div>

Hi,

Try to use a conditional.  
Something like

if "Failed password for root" in [syslog\_message] {  
elasticsearch {

}

}

---

<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 17, 2017, 6:54pm UTC](https://discuss.elastic.co/t/filtering-rules-in-logstash/86463/3 "2017-06-17T18:54:51Z")

</div>

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