<div dir="ltr"><div>Hi Team,</div><div><br></div><div>Well, I am working on a POC using the syslog-ng 3.7.1, basically, I have many of log files that the filename is /path/<file> and I need to append the file name into the syslog payload.</div><div><br></div><div>My current approach is.</div><div><br></div><div>1. I have the below destination() receiving the file name as a parameter. </div><div><br></div><div><snip></div><div>block destination d_collector_with_fn(__filename("")) {</div><div> tcp("192.168.2.44"</div><div> port(514)</div><div> keep-alive(on)</div><div> template("$DATE $HOST $MSGHDR $(format-json --scope selected_macros \</div><div> --exclude TAGS \</div><div> --exclude DATE \</div><div> --exclude PRIORITY \</div><div> --exclude FACILITY \</div><div> --exclude SOURCEIP \</div><div> --exclude PROGRAM \</div><div> --pair SYSLOG_WEBAPP_DOMAIN='`__filename`' \</div><div> --pair SOURCE=${SOURCE}</div><div> )\n")</div><div> template-escape(no)</div><div> ); </div><div>};</div><div></snip></div><div><br></div><div><br></div><div>2. My simple script called by confgen create some dynamic "log {}" statements listening to the files and appending the filename as a parameter to the d_collector_with_fn()</div><div><br></div><div><snip></div><div>log {</div><div> source {</div><div> file("/path/<a href="http://thisisafile001.net">thisisafile001.net</a>"</div><div> program_override("mytag")</div><div> follow_freq(1)</div><div> flags(no-parse)</div><div> );</div><div> };</div><div> destination {</div><div> d_collector_with_fn(__filename("<a href="http://thisisafile001.net">thisisafile001.net</a>"));</div><div> };</div><div>};</div><div><br></div><div>log {</div><div> source {</div><div> file("<a href="http://caipirinha4ever.net">caipirinha4ever.net</a>"</div><div> program_override("mytag")</div><div> follow_freq(1)</div><div> flags(no-parse)</div><div> );</div><div> };</div><div> destination {</div><div> d_collector_with_fn(__filename("<a href="http://caipirinha4ever.net">caipirinha4ever.net</a>"));</div><div> };</div><div>};</div><div><br></div><div>.........................</div><div></snip></div><div><br></div><div>But, I have more than 5k files and my current approach creating multiples log { } statement resulting in one connection to the collector by each file!!! in this case, I have 5k connections... this is terrible, someone has some other suggestion? exist some way to catch the filename by some internal ${variable} and pass for a single destination()?</div><div><br></div><div>--</div><div>Jorge Pereira</div>
</div>