I am using logstash 1.4.2,
I have logstash-forwarder.conf in a client log server, like this
{ "network": { "servers": [ "xxx.xxx.xxx.xxx:5000" ], "timeout": 15, "ssl ca": "certs/logstash-forwarder.crt" }, "files": [ { "paths": [ "/var/log/messages" ], "fields": { "type": "syslog" } }, { "paths": [ "/var/log/secure" ], "fields": { "type": "linux-syslog" } } ] }
==================================================== =======
In logstash server
1. filter.conf
filter { if [type] == "syslog" { date { locale => "en" match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"] timezone => "Asia/Kathmandu" target => "@timestamp" add_field => { "debug" => "timestampMatched"} } grok { match => { "message" => "\[%{WORD:messagetype}\]%{GREEDYDATA:syslog_message}" } add_field => [ "received_at", "%{@timestamp}" ] add_field => [ "received_from", "%{host}" ] } syslog_pri { } } if [type] == "linux-syslog" { date { locale => "en" match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"] timezone => "Asia/Kathmandu" target => "@timestamp" add_field => { "debug" => "timestampMatched"} } 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 { } mutate { replace => [ "syslog_timestamp", "%{syslog_timestamp} +0545" ] } } }
==================================================== =====
2. output.conf
output { if [messagetype] == "WARNING" { elasticsearch { host => "xxx.xxx.xxx.xxx" } stdout { codec => rubydebug } } if [messagetype] == "ERROR" { elasticsearch { host => "xxx.xxx.xxx.xxx" } stdout { codec => rubydebug } } if [type] == "linux-syslog" { elasticsearch { host => "xxx.xxx.xxx.xxx" } stdout { codec => rubydebug } } }
==================================================== =====
I want all the logs to go from / var / log / secure and only ERROR and WARNING are logged from / var / log / messages, I know this is not a very good configuration. I want someone to show me the best way to do this.
logstash kibana
Err0rr
source share