Hello, this is with syslog output (the if conditional it's for testing too, it's a lab actually),
[root@pajaroto conf.d]# cat logstash-syslog.conf
### Input Section
input {
tcp {
port => 514
type => syslog
}
udp {
port => 514
type => syslog
}
}
### Filter Section
filter {
if [type] == "syslog" {
grok {
match => { "message" => "<%{POSINT:syslog_pri}>%{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" ]
}
}
}
### Output Section
output {
stdout { codec => rubydebug }
if "Hola" in [message] {
elasticsearch { hosts => ["localhost:9200"] }
}
else {
elasticsearch { hosts => ["localhost:9200"] }
syslog {
host => "192.168.0.30"
port => 514
protocol => "tcp"
}
}
}
all it's ok, but sends the logstash header and "changes" the piority of event (example:
<13>Apr 16 18:32:46 192.168.0.58 LOGSTASH[-]: <86>Apr 16 20:32:46 howard sshd[3072]: pam_unix(sshd:session): session closed for user robe
this event has a prioriy of 86 (info/auth) but it's change to 13 (user/notice) and timestamp, host and LOGSTASH it's added too
and this is the TCP output configuration:
### Input Section
input {
tcp {
port => 514
type => syslog
}
udp {
port => 514
type => syslog
}
}
### Filter Section
filter {
if [type] == "syslog" {
grok {
match => { "message" => "<%{POSINT:syslog_pri}>%{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" ]
}
}
}
### Output Section
output {
stdout { codec => rubydebug }
if "Hola" in [message] {
elasticsearch { hosts => ["localhost:9200"] }
}
else {
elasticsearch { hosts => ["localhost:9200"] }
tcp{
host => "192.168.0.30"
port => 514
codec => line {
format => " %{message}"
}
}
}
the event it's ok, but the source IP in this case it's not 192.168.0.58 (the server sending logs to LOGSTASH, it's 192.168.0.57, the LOGSTASH server it selfs)
<77>Apr 14 10:06:01 howard anacron[10849]: Normal exit (1 job run)
perhaps the main poblem when I use TCP it's in the server receiving from LOGSTASH, the question it's in syslog output is there anyway to remove "logstash header" or in TCP output, is there anyway to matain source IP from server generating event?
thanks for your help