<?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 Re: Filed Extraction on Text File in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137699#M37753</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;You could use a rex like this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;field1&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field2&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field3&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field4&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field5&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field6&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field7&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field8&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field9&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field10&amp;gt;[^\s]+)?(\s)?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add as fields as the maximun number of fields you could have in the log file&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2014 10:42:08 GMT</pubDate>
    <dc:creator>gfuente</dc:creator>
    <dc:date>2014-02-05T10:42:08Z</dc:date>
    <item>
      <title>Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137698#M37752</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have Host Firewall Logs coming in a text file. The data in the text file is separated by spaces and is inconsistent as for some rows there are say 8 columns, in some there are fewer and in some greater than 8 columns. I want to perform filed extraction on this data. How can this be achieved? I am familiar with csv field extraction but there the data is not inconsistent as is the case with this text file. I am using Splunk v5.0.5.&lt;/P&gt;

&lt;P&gt;Please help. Its quite urgent. Any help would be really appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 10:09:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137698#M37752</guid>
      <dc:creator>garima_chauhan</dc:creator>
      <dc:date>2014-02-05T10:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137699#M37753</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;You could use a rex like this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;field1&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field2&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field3&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field4&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field5&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field6&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field7&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field8&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field9&amp;gt;[^\s]+)?(\s)?(?&amp;lt;field10&amp;gt;[^\s]+)?(\s)?
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add as fields as the maximun number of fields you could have in the log file&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 10:42:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137699#M37753</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2014-02-05T10:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137700#M37754</link>
      <description>&lt;P&gt;Hi gfuente,&lt;/P&gt;

&lt;P&gt;My log file looks like:&lt;/P&gt;

&lt;P&gt;7   123456  1.1.1.1     sfgdfghdghgdh   25  6   2.2.2.2     5255225     3.3.3.3     80  1   1   0   sdgzdfsg&lt;BR /&gt;
7   456789  1.1.1.1     fsdfgsfgsfgfv   52  6   3.3.3.3     4654646     5.5.5.5     4564    2   2   2   pathoffile  ssdfgsfg&lt;BR /&gt;
7   123456  1.1.1.1     sfgdfghdghgdh   25  6   2.2.2.2     5255225     3.3.3.3     80  1   1   0   pathoffilevzfsgfgjsdlgjlsggflkgj        sdgzdfsg&lt;/P&gt;

&lt;P&gt;I am guessing that the column number discrepancy is due to the fact that if one column value is blank, it is not left blank and is instead populated with the next column value.&lt;/P&gt;

&lt;P&gt;In any case, I do not how how to tackle this. Please help.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 11:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137700#M37754</guid>
      <dc:creator>garima_chauhan</dc:creator>
      <dc:date>2014-02-05T11:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137701#M37755</link>
      <description>&lt;P&gt;Your sample lines have more than one space between some fields. Thats different from what you explained in your original question. try this:&lt;/P&gt;

&lt;P&gt;| rex "^(?&lt;FIELD1&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD2&gt;[^\s]+)?(\s)&lt;/FIELD2&gt;&lt;/EM&gt;(?&lt;FIELD3&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD4&gt;[^\s]+)?(\s)&lt;/FIELD4&gt;&lt;/EM&gt;(?&lt;FIELD5&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD6&gt;[^\s]+)?(\s)&lt;/FIELD6&gt;&lt;/EM&gt;(?&lt;FIELD7&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD8&gt;[^\s]+)?(\s)&lt;/FIELD8&gt;&lt;/EM&gt;(?&lt;FIELD9&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD10&gt;[^\s]+)?(\s)&lt;/FIELD10&gt;&lt;/EM&gt;(?&lt;FIELD11&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD12&gt;[^\s]+)?(\s)&lt;/FIELD12&gt;&lt;/EM&gt;(?&lt;FIELD13&gt;[^\s]+)?(\s)&lt;EM&gt;(?&lt;FIELD14&gt;[^\s]+)?(\s)&lt;/FIELD14&gt;&lt;/EM&gt;(?&lt;FIELD15&gt;[^\s]+)?(\s)*" &lt;/FIELD15&gt;&lt;/FIELD13&gt;&lt;/FIELD11&gt;&lt;/FIELD9&gt;&lt;/FIELD7&gt;&lt;/FIELD5&gt;&lt;/FIELD3&gt;&lt;/FIELD1&gt;&lt;/P&gt;

&lt;P&gt;This works with the sample data you had provided&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 12:24:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137701#M37755</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2014-02-05T12:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137702#M37756</link>
      <description>&lt;P&gt;Hi, I tried the following search:&lt;BR /&gt;
source=FirewallLogs | rex "^(?&lt;FIELD1&gt;[^s]+)?(s)(?&lt;FIELD2&gt;[^s]+)?(s)(?&lt;FIELD3&gt;[^s]+)?(s)(?&lt;FIELD4&gt;[^s]+)?(s)(?&lt;FIELD5&gt;[^s]+)?(s)(?&lt;FIELD6&gt;[^s]+)?(s)(?&lt;FIELD7&gt;[^s]+)?(s)(?&lt;FIELD8&gt;[^s]+)?(s)(?&lt;FIELD9&gt;[^s]+)?(s)(?&lt;FIELD10&gt;[^s]+)?(s)(?&lt;FIELD11&gt;[^s]+)?(s)(?&lt;FIELD12&gt;[^s]+)?(s)(?&lt;FIELD13&gt;[^s]+)?(s)(?&lt;FIELD14&gt;[^s]+)?(s)(?&lt;FIELD15&gt;[^s]+)?(s)*" | table field1 field2&lt;/FIELD15&gt;&lt;/FIELD14&gt;&lt;/FIELD13&gt;&lt;/FIELD12&gt;&lt;/FIELD11&gt;&lt;/FIELD10&gt;&lt;/FIELD9&gt;&lt;/FIELD8&gt;&lt;/FIELD7&gt;&lt;/FIELD6&gt;&lt;/FIELD5&gt;&lt;/FIELD4&gt;&lt;/FIELD3&gt;&lt;/FIELD2&gt;&lt;/FIELD1&gt;&lt;/P&gt;

&lt;P&gt;but, nothing gets displayed.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2014 07:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137702#M37756</guid>
      <dc:creator>garima_chauhan</dc:creator>
      <dc:date>2014-02-06T07:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137703#M37757</link>
      <description>&lt;P&gt;There are missing characters, please see this update:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "^(?&amp;lt;field1&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field2&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field3&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field4&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field5&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field6&amp;gt;[^\s]+)?(\s)\*(?&amp;lt;field7&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field8&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field9&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field10&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field11&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field12&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field13&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field14&amp;gt;[^s]+)?(\s)\*(?&amp;lt;field15&amp;gt;[^s]+)?(\s)\*" | ... 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2014 10:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137703#M37757</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2014-02-06T10:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Filed Extraction on Text File</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137704#M37758</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Still didnt work..:(&lt;BR /&gt;
I copied this exact regex.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2014 13:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filed-Extraction-on-Text-File/m-p/137704#M37758</guid>
      <dc:creator>garima_chauhan</dc:creator>
      <dc:date>2014-02-06T13:01:55Z</dc:date>
    </item>
  </channel>
</rss>

