<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 20, 2018 at 7:21 AM, Nagy, Gábor <span dir="ltr"><<a href="mailto:gabor.nagy@balabit.com" target="_blank">gabor.nagy@balabit.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Asif!<br><br>I think the problem with the first message comes from the message structure and the filter statement.<div>Its structure does not conform to either syslog RFC standards (RFC3164 or RFC5424).</div><div>Syslog-ng still tries to parse the log message by its internal heuristics and the "alarmLog" text is parsed as the 'program' field.</div><div>You can debug syslog-ng parsing with the format-json template in the destination:</div><div>        `template("$(format-json -s syslog-proto)\n")`</div><div><br></div><div>The output for this was:</div><div><div>{"PROGRAM":"alarmLog,","<wbr>PRIORITY":"notice","MESSAGE":"<wbr>applianceName=Branch-UC1, tenantName=DEMO-CORP, alarmType=sla-not-met, alarmKey=INTERNET, generateTime=1521503387, applianceId=1, vsnId=0, tenantId=2, alarmCause=datapathState, alarmClearable=yes, alarmClass=cleared, alarmKind=symptom, alarmEventType=equipmentAlarm, alarmSeverity=cleared, alarmOwner=tenant, alarmSeqNo=1568, alarmText=delay:9 msec, siteName=Branch-UC1","HOST":"+<wbr>0000","FACILITY":"user","DATE"<wbr>:"Mar 13 23:49:48"}</div></div><div><br></div><div>The filter statement uses the `match()` filter which works on both the header and message part of the log message and thus would match for the first log message if the `value("MESSAGE")` part would not be there.</div><div>With that you restricted the filter to match only on the message part.</div><div>If you remove the value("MESSAGE") from the filter statement it will work.<br></div></div></blockquote><div><br></div><div>That was it. It is working now!! </div><div><br></div><div>BTW, is there a way to generate a feed a pcap to some program on the terminal to generate a json formatted output like this short from modifying the syslog-ng config</div><div>for destination to a template like you are showing?</div><div><br></div><div>Thanks for your help and I see the logs being written to the file now!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>Regards,</div><div>Gabor</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Mar 20, 2018 at 1:52 AM, Asif Iqbal <span dir="ltr"><<a href="mailto:vadud3@gmail.com" target="_blank">vadud3@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>syslog-ng is <b><font color="#ff0000">NOT</font></b> writing syslog like this to a file which has no <<b>PRI</b>></div><div><br></div><div>23:49:48.306587 IP 192.168.1.100.39567 > 192.168.100.100.514: [|syslog]</div><div>E.....@.>..U...g..........T.20<wbr>18-03-19T23:49:48+0000 alarmLog, applianceName=Branch-UC1, tenantName=DEMO-CORP, alarmType=sla-not-met, alarmKey=INTERNET, generateTime=1521503387, applianceId=1, vsnId=0, tenantId=2, alarmCause=datapathState, alarmClearable=yes, alarmClass=cleared, alarmKind=symptom, alarmEventType=equipmentAlarm, alarmSeverity=cleared, alarmOwner=tenant, alarmSeqNo=1568, alarmText="delay:9 msec", siteName=Branch-UC1</div><div>................</div><div><br></div><div><br></div><div>syslog-ng is writing syslog like this to a file <b>OK </b></div><div><br></div><div>23:50:26.930023 IP 192.168.1.100.55078 > 192.168.100.100.514: SYSLOG <a href="http://mail.info" target="_blank">mail.info</a>, length: 76</div><div>E..h.B@.>......g.....&...Tt.<2<wbr>2>Mar 19 23:50:26 SVL-remotehost-02 root: this is third test alarmLog................</div><div><br></div><div><br></div><div>Here is my syslog-ng config</div><div>    source s_udp { udp(ip(0.0.0.0) port(514)); };<br></div><div><div>    destination d_alarm { file("/var/log/alarms.log"); };</div><div>    filter f_alarm { match("alarmLog" value("MESSAGE")); };<br></div><div>    log { source(s_udp); filter(f_alarm); destination(d_alarm); };<br></div></div><div><br></div><div>I am using syslog-ng version 3.5.6 on centos 7</div><div><br></div><div>Any idea why syslog-ng is writing the first log event into a file?</div><div><br></div><div>Appreciate any help!</div><span class="m_5195631471607390889HOEnZb"><font color="#888888"><div><br></div><div><br></div>-- <br><div class="m_5195631471607390889m_-7794152780587771181gmail_signature">Asif Iqbal<br>PGP Key: 0xE62693C5 KeyServer: <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>A: Because it messes up the order in which people normally read text.<br>Q: Why is top-posting such a bad thing?<br><br></div>
</font></span></div>
<br></div></div>______________________________<wbr>______________________________<wbr>__________________<br>
Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailm<wbr>an/listinfo/syslog-ng</a><br>
Documentation: <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support<wbr>/documentation/?product=<wbr>syslog-ng</a><br>
FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/sy<wbr>slog-ng-faq</a><br>
<br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>______________________________<wbr>__________________<br>
Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/<wbr>mailman/listinfo/syslog-ng</a><br>
Documentation: <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/<wbr>support/documentation/?<wbr>product=syslog-ng</a><br>
FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/<wbr>syslog-ng-faq</a><br>
<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Asif Iqbal<br>PGP Key: 0xE62693C5 KeyServer: <a href="http://pgp.mit.edu" target="_blank">pgp.mit.edu</a><br>A: Because it messes up the order in which people normally read text.<br>Q: Why is top-posting such a bad thing?<br><br></div>
</div></div>