<?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: How do I handle fields with no value or a blank space in a rex field extraction so they show up as null? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208200#M60704</link>
    <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search | rex "^[^\|]+\|(?&amp;lt;event&amp;gt;[^\|]*)\|\s(?&amp;lt;subject&amp;gt;[^\|]*)\|\s(?&amp;lt;ip&amp;gt;[^\|]*)\|\s(?&amp;lt;app&amp;gt;[^\|]*)\|\s(?&amp;lt;connectionid&amp;gt;[^\|]*)\|\s(?&amp;lt;protocol&amp;gt;[^\|]*)\|\s(?&amp;lt;host&amp;gt;[^\|]*)\|\s(?&amp;lt;role&amp;gt;[^\|]*)\|\s(?&amp;lt;status&amp;gt;[^\|]*)\|\s(?&amp;lt;adapterid&amp;gt;[^\|]*)\|\s(?&amp;lt;description&amp;gt;[^\|]*)\|\s(?&amp;lt;responsetime&amp;gt;.\d*)"  | replace ""  with "NA"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 Feb 2016 22:56:10 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-02-18T22:56:10Z</dc:date>
    <item>
      <title>How do I handle fields with no value or a blank space in a rex field extraction so they show up as null?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208197#M60701</link>
      <description>&lt;P&gt;I have a data source that is pipe delimited, but some of the fields contain no data or even a blank space. I've created a regex expression that is able to extract all the fields, but is there a way to have the fields with no value or a blank space show up as null so I can handle them with fillnull? Currently the show up as blank such as &lt;CODE&gt;event=""&lt;/CODE&gt; or with a space like &lt;CODE&gt;subject=" "&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Raw data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-18 09:35:09,491|OAuth| USER1| 1.1.1.1 | |USER1| OAuth20| pingfedserver4| AS| success| | | 18 
2016-02-18 09:35:09,267|SSO| USER2| 2.2.2.2 | | &lt;A href="https://testsite.test.com|" target="test_blank"&gt;https://testsite.test.com|&lt;/A&gt; SAML20| pingfedserver4| IdP| success| testuser| | 92 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My rex statement:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\d*\:\d*:\d*\,\d*\|(?&amp;lt;event&amp;gt;[^\|]*)\|(?&amp;lt;subject&amp;gt;[^\|]*)\|(?&amp;lt;ip&amp;gt;[^\|]*)\|(?&amp;lt;app&amp;gt;[^\|]*)\|(?&amp;lt;connectionid&amp;gt;[^\|]*)\|(?&amp;lt;protocol&amp;gt; [^\|]*)\|(?&amp;lt;host&amp;gt;[^\|]*)\|(?&amp;lt;role&amp;gt;[^\|]*)\|(?&amp;lt;status&amp;gt;[^\|]*)\|(?&amp;lt;adapterid&amp;gt;[^\|]*)\|(?&amp;lt;description&amp;gt;[^\|]*)\|(?&amp;lt;responsetime&amp;gt;[^\|]*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Feb 2016 15:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208197#M60701</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2016-02-18T15:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I handle fields with no value or a blank space in a rex field extraction so they show up as null?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208198#M60702</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've noticed a typo in your regex. There's a space after the protocol label that it shouldn't be there.&lt;/P&gt;

&lt;P&gt;Anyway, with regards to your questions, you could combine foreach with trim and isnull and it should give you what you are looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| foreach * [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = if(isnull(trim('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')), "NULL", trim('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'))]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if that helps&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 16:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208198#M60702</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-02-18T16:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I handle fields with no value or a blank space in a rex field extraction so they show up as null?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208199#M60703</link>
      <description>&lt;P&gt;That didn't quite handle it, but I was able to get of rid of the spaces by changing my rex command a bit.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\d*\:\d*:\d*\,\d*\|(?&amp;lt;event&amp;gt;[^\|]*)\|\s(?&amp;lt;subject&amp;gt;[^\|]*)\|\s(?&amp;lt;ip&amp;gt;[^\|]*)\|\s(?&amp;lt;app&amp;gt;[^\|]*)\|\s(?&amp;lt;connectionid&amp;gt;[^\|]*)\|\s(?&amp;lt;protocol&amp;gt;[^\|]*)\|\s(?&amp;lt;host&amp;gt;[^\|]*)\|\s(?&amp;lt;role&amp;gt;[^\|]*)\|\s(?&amp;lt;status&amp;gt;[^\|]*)\|\s(?&amp;lt;adapterid&amp;gt;[^\|]*)\|\s(?&amp;lt;description&amp;gt;[^\|]*)\|\s(?&amp;lt;responsetime&amp;gt;.\d*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I just need to be able to handle where myfield=""&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2016 19:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208199#M60703</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2016-02-18T19:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I handle fields with no value or a blank space in a rex field extraction so they show up as null?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208200#M60704</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search | rex "^[^\|]+\|(?&amp;lt;event&amp;gt;[^\|]*)\|\s(?&amp;lt;subject&amp;gt;[^\|]*)\|\s(?&amp;lt;ip&amp;gt;[^\|]*)\|\s(?&amp;lt;app&amp;gt;[^\|]*)\|\s(?&amp;lt;connectionid&amp;gt;[^\|]*)\|\s(?&amp;lt;protocol&amp;gt;[^\|]*)\|\s(?&amp;lt;host&amp;gt;[^\|]*)\|\s(?&amp;lt;role&amp;gt;[^\|]*)\|\s(?&amp;lt;status&amp;gt;[^\|]*)\|\s(?&amp;lt;adapterid&amp;gt;[^\|]*)\|\s(?&amp;lt;description&amp;gt;[^\|]*)\|\s(?&amp;lt;responsetime&amp;gt;.\d*)"  | replace ""  with "NA"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Feb 2016 22:56:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208200#M60704</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-18T22:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I handle fields with no value or a blank space in a rex field extraction so they show up as null?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208201#M60705</link>
      <description>&lt;P&gt;Worked perfectly! I didn't know about the replace command.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 14:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-handle-fields-with-no-value-or-a-blank-space-in-a-rex/m-p/208201#M60705</guid>
      <dc:creator>jedatt01</dc:creator>
      <dc:date>2016-02-19T14:05:36Z</dc:date>
    </item>
  </channel>
</rss>

