hi there
we are using logstash for logging syslog events to file and forward to elastic.
Our configs are s follows:
input {
syslog {
id => "Syslog_Data"
port => 5514
type => syslog
codec => plain{ charset => "ISO-8859-1" }
tags => ["noelastic"]
add_field => { "client-service" => "syslog" }
}
}
output {
if ([type] =~ /^syslog$/) and ("noelastic" not in [tags]) {
elasticsearch
{
id => "currently_not_used"
hosts => ["els01:9200", "els03:9200","els04:9200","els05.:9200"]
index => "syslog-%{+YYYY.MM.dd}"
}
}
if ([type] =~ /^syslog$/) and ("nosavelogs" not in [tags]) {
if ("local4" in [facility_label]) {
file {
path => "/logstash-data/nfs-service/%{client-service}/%{+YYYY}/%{+MM-YYYY}/%{+dd-MM-YYYY}/%{host}/syslog_log-%{+YYYYMMdd}"
codec => line { format => "%{timestamp} %{host} %{logsource} %{program} %{pid} : %{message}" }
id => "syslog_logs"
}
}}
But we sometime get extra characters injected at the start of the events when written to file.
We dont see those extra characters, when we explore same data in kibana, which points us to File output plugin of logstash.
For example see Sample data in file with extra characters at the start of event
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@Dec 19 10:01:04 a.b.c.d Oracle Audit 8009 : LENGTH: "231" SESSIONID:[7] "7425390" ENTRYID:[1] "1" USERID:[6] "xyz" ACTION:[3] "101" RETURNCODE:[1] "0" LOGOFF$PREAD:[3] "253" LOGOFF$LREAD:[4] "1884" LOGOFF$LWRITE:[3] "848" LOGOFF$DEAD:[1] "0" DBID:[10] "155789743982" SESSIONCPU:[2] "10"
while the same event in kibana is without any extra characters at the start.
Can somebody please guide on this.
Thanks