<?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: Field Extraction (Regex) When Column Is Sometimes Absent in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156772#M44105</link>
    <description>&lt;P&gt;Ayn, I actually read your notes here: &lt;A href="http://answers.splunk.com/answers/67170/index-time-field-extraction"&gt;http://answers.splunk.com/answers/67170/index-time-field-extraction&lt;/A&gt; about using search-time extractions....and I just learned what the difference is from the docs!&lt;/P&gt;</description>
    <pubDate>Tue, 26 Nov 2013 22:18:23 GMT</pubDate>
    <dc:creator>RMartinezDTV</dc:creator>
    <dc:date>2013-11-26T22:18:23Z</dc:date>
    <item>
      <title>Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156765#M44098</link>
      <description>&lt;P&gt;Hi, I'm working on a Regex for field extractions of an alert log. The log has 1 line per alert in the following format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[11/26/2013 9:13:41 AM]     Server1 LogTest: /var/log   Ok      Text Log test
[11/26/2013 9:13:36 AM]     Server1 LogTest: /var/log   Bad &amp;lt;......data.......&amp;gt; Text Log test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The difficulty comes when handling some OK statuses; you'll notice here that a 'Bad' status returns data (the relevant log lines), but an 'Ok' status returns a blank (actually 2 tabs) data section.&lt;/P&gt;

&lt;P&gt;It seems like every regex I come up with will accidentally capture some part of &lt;CODE&gt;Text Log test&lt;/CODE&gt; and use that as part of all of the &lt;CODE&gt;data&lt;/CODE&gt; section when &lt;CODE&gt;data&lt;/CODE&gt; isn't present.&lt;/P&gt;

&lt;P&gt;Can I get some pointers on the proper regex expression? My current regex is below, and I think I've exhausted the guess and check method. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;]\t+\s+(?P&amp;lt;server&amp;gt;.+?)\s+(?P&amp;lt;category&amp;gt;.+?)\s(?P&amp;lt;object&amp;gt;.+?)\t(?P&amp;lt;status&amp;gt;.+?)\t(?P&amp;lt;data&amp;gt;.+?)\t(?P&amp;lt;test&amp;gt;.+?)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2013 17:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156765#M44098</guid>
      <dc:creator>RMartinezDTV</dc:creator>
      <dc:date>2013-11-26T17:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156766#M44099</link>
      <description>&lt;P&gt;Have you tried setting this up for search time extraction using the log delimiter and a preset series of fields?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 17:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156766#M44099</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-11-26T17:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156767#M44100</link>
      <description>&lt;P&gt;DELIMS doesn't work as an index-time extraction, and index-time extractions should be avoided unless you really know what you're doing and why.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 18:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156767#M44100</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-11-26T18:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156768#M44101</link>
      <description>&lt;P&gt;My mistake, a search time field extraction.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 18:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156768#M44101</guid>
      <dc:creator>lukejadamec</dc:creator>
      <dc:date>2013-11-26T18:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156769#M44102</link>
      <description>&lt;P&gt;Would it work better if you change the end &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;status&amp;gt;.+?)\t(?P&amp;lt;data&amp;gt;.+?)\t(?P&amp;lt;test&amp;gt;.+?)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?P&amp;lt;status&amp;gt;.+)\t(?P&amp;lt;data&amp;gt;.*)\t(?P&amp;lt;test&amp;gt;.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then you &lt;DATA&gt; should match to an empty string if there is just 2 tabs in case of "Ok"? It sounds too easy and I didn't test it with Splunk, so maybe I'm missing something?&lt;/DATA&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 20:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156769#M44102</guid>
      <dc:creator>kallu</dc:creator>
      <dc:date>2013-11-26T20:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156770#M44103</link>
      <description>&lt;P&gt;Thanks! This was almost perfect. See my answer below.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 22:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156770#M44103</guid>
      <dc:creator>RMartinezDTV</dc:creator>
      <dc:date>2013-11-26T22:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156771#M44104</link>
      <description>&lt;P&gt;Probably tacky to accept my own answer, but here's the final result for reference:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;]\t+\s+(?P&amp;lt;server&amp;gt;.+?)\s+(?P&amp;lt;category&amp;gt;.+?):\s(?P&amp;lt;object&amp;gt;.+?)\t(?P&amp;lt;status&amp;gt;.+?)\t(?P&amp;lt;data&amp;gt;.*)\t(?P&amp;lt;test&amp;gt;.*)\t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This correctly matches event when a field has blank data. Adjust punctuation (\t,\s,:, and ]) as needed for your data.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 22:17:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156771#M44104</guid>
      <dc:creator>RMartinezDTV</dc:creator>
      <dc:date>2013-11-26T22:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Field Extraction (Regex) When Column Is Sometimes Absent</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156772#M44105</link>
      <description>&lt;P&gt;Ayn, I actually read your notes here: &lt;A href="http://answers.splunk.com/answers/67170/index-time-field-extraction"&gt;http://answers.splunk.com/answers/67170/index-time-field-extraction&lt;/A&gt; about using search-time extractions....and I just learned what the difference is from the docs!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 22:18:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Extraction-Regex-When-Column-Is-Sometimes-Absent/m-p/156772#M44105</guid>
      <dc:creator>RMartinezDTV</dc:creator>
      <dc:date>2013-11-26T22:18:23Z</dc:date>
    </item>
  </channel>
</rss>

