<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ncftpd log extractions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/ncftpd-log-extractions/m-p/59682#M14703</link>
    <description>&lt;P&gt;I'm trying to do field extractions for ncftpd xfer logs.  These are generally csv but the fields differ depending on what operation is being logged ( &lt;A href="http://ncftpd.com/ncftpd/doc/xferlog.html"&gt;http://ncftpd.com/ncftpd/doc/xferlog.html&lt;/A&gt; if you want the details.)&lt;/P&gt;

&lt;P&gt;Is there a clean way to extract the first few generic fields and do the other field extractions depending on the values extracted?  Let's call the first field 'operation'.  Can I say something like&lt;/P&gt;

&lt;P&gt;search operation="S" OR operation="R" | do field extractions specific to these&lt;BR /&gt;
search operation="T" | do field extractions specific to this&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jan 2012 19:17:53 GMT</pubDate>
    <dc:creator>jspears</dc:creator>
    <dc:date>2012-01-27T19:17:53Z</dc:date>
    <item>
      <title>ncftpd log extractions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ncftpd-log-extractions/m-p/59682#M14703</link>
      <description>&lt;P&gt;I'm trying to do field extractions for ncftpd xfer logs.  These are generally csv but the fields differ depending on what operation is being logged ( &lt;A href="http://ncftpd.com/ncftpd/doc/xferlog.html"&gt;http://ncftpd.com/ncftpd/doc/xferlog.html&lt;/A&gt; if you want the details.)&lt;/P&gt;

&lt;P&gt;Is there a clean way to extract the first few generic fields and do the other field extractions depending on the values extracted?  Let's call the first field 'operation'.  Can I say something like&lt;/P&gt;

&lt;P&gt;search operation="S" OR operation="R" | do field extractions specific to these&lt;BR /&gt;
search operation="T" | do field extractions specific to this&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2012 19:17:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ncftpd-log-extractions/m-p/59682#M14703</guid>
      <dc:creator>jspears</dc:creator>
      <dc:date>2012-01-27T19:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: ncftpd log extractions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/ncftpd-log-extractions/m-p/59683#M14704</link>
      <description>&lt;P&gt;You can't automate a conditional delimiter-based field extraction, but you can define one unique field extraction per type of xferlog event and select which one to apply using the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank"&gt;extract&lt;/A&gt; command.&lt;/P&gt;

&lt;P&gt;First, define an automatic field extraction for the "operation" field, the value of which should determine which delimiter-based extraction we will apply.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;props.conf:&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;CODE&gt;[xferlog]&lt;BR /&gt;
EXTRACT-operation = ^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}[^|]*\|\s+(?&lt;OPERATION&gt;\w),&lt;/OPERATION&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Now in &lt;A href="http://www.splunk.com/base/Documentation/latest/Admin/Transformsconf" target="_blank"&gt;transforms.conf&lt;/A&gt;, define one delimiter-based field extraction for each type of event. As an example, based on the xferlog reference page here's one definition for the S and R log entry types and one for the T (directory listing) log entry type.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;transforms.conf:&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;&lt;CODE&gt;[fields_store_retrieve]&lt;BR /&gt;
DELIMS = ","&lt;BR /&gt;
FIELDS = "Head","Pathname","Size","Duration","Rate","User","Email","Host","Suffix","Completion","Transfer_Type","Transfer_notes","Start_of_transfer","Session_ID","Starting_size","Starting_offset"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[fields_dirlist]&lt;BR /&gt;
DELIMS = ","&lt;BR /&gt;
FIELDS = "Head","Pathname","Completion","Pattern","Recursion","User","Email","Host","Session ID"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Now when you search, apply the appropriate field extraction depending on the value of the "operation" field of the events you are querying :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xferlog operation=R OR operation=S | extract fields_store_retrieve
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;or&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xferlog operation=T | extract fields_dirlist
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's too bad that one cannot define automatic field extractions based on &lt;A href="http://docs.splunk.com/Splexicon:Eventtype" target="_blank"&gt;event types&lt;/A&gt; because this would have been an ideal use-case for that.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/ncftpd-log-extractions/m-p/59683#M14704</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2020-09-28T10:22:21Z</dc:date>
    </item>
  </channel>
</rss>

