<?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: Why does the regex work in search but not in props.conf? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288995#M87479</link>
    <description>&lt;P&gt;try setting &lt;CODE&gt;INDEXED_VALUE = false&lt;/CODE&gt; in fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[user_org]
INDEXED_VALUE = false
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Feb 2018 17:10:35 GMT</pubDate>
    <dc:creator>493669</dc:creator>
    <dc:date>2018-02-16T17:10:35Z</dc:date>
    <item>
      <title>Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288992#M87476</link>
      <description>&lt;P&gt;I have a file that I am monitoring on a Heavy Forwarder(HF). The file is JSON logs. On the HF I have the following props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[EC-json]
KV_MODE=JSON
TIME_PREFIX="timestamp":"
TIME_FORMAT=%Y-%m-%dT%H:%M:%S
SHOULD_LINEMERGE=false
TRUNCATE=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After the file gets to the indexers, from the SH, I am trying to create several search time extractions.&lt;/P&gt;

&lt;P&gt;I first tested from the search bar using this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=EC-json | rex field =_raw "userid\":.+?,ou=(?&amp;lt;user_org&amp;gt;\w+)," | rex field = _raw "SourceName.+?:.+?\/\/.+\/(?&amp;lt;PDF&amp;gt;.+?\.pdf)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This was successful, I was able to create two new fields user_org and PDF.&lt;/P&gt;

&lt;P&gt;Then I tried using props.conf in /etc/apps/search/local/ on the SH:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[EC-json]
EXTRACT-user_org = userid\".+?,ou=(?&amp;lt;user_org&amp;gt;\w+),
EXTRACT-PDF = SourceName\".+?:.+?\/\/.+\/(?&amp;lt;PDF&amp;gt;.+?\.pdf)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is a sample of my data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"timestamp":"02/16/2018 08:02:23","Accountid":"userj", &amp;lt;snip&amp;gt; ,"SourceName":"https://share.org.com/sites/reports/ORGReports/report1.pdf","userid":"cn= joe user,ou=SOC,ou=org,ou=company,ou=us"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using the suggestions here:  &lt;A href="https://www.splunk.com/blog/2016/06/28/eureka-extracting-key-value-pairs-from-json-fields.html"&gt;https://www.splunk.com/blog/2016/06/28/eureka-extracting-key-value-pairs-from-json-fields.html&lt;/A&gt;&lt;BR /&gt;
 and added the following to the props.conf on my SH to pull all the information from the userid:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-KVPS = (?:\\[rnt]|:")(?&amp;lt;_KEY_1&amp;gt;[^="\\]+)=(?:\\")?(?&amp;lt;_VAL_1&amp;gt;[^="\\]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that doesn't seem to pull the info into the right fields.  And all I care about is the first OU anyway.&lt;/P&gt;

&lt;P&gt;Can someone help with my props.conf syntax?&lt;BR /&gt;&lt;BR /&gt;
Do I need to escape the quote after userid and SourceName or not?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 16:04:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288992#M87476</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2018-02-16T16:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288993#M87477</link>
      <description>&lt;P&gt;Try this (props.conf on SH, will need to restart SH)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[EC-json]
EXTRACT-user_org = userid\"\:\"[^,]+,ou=(?&amp;lt;user_org&amp;gt;[^,]+)
EXTRACT-PDF = SourceName\"\:\"([^\/]+\/+)+(?&amp;lt;PDF&amp;gt;[^\.]+\.pdf)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2018 16:46:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288993#M87477</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-02-16T16:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288994#M87478</link>
      <description>&lt;P&gt;What about trying the following regex in an auto field extraction (though the Splunk UI Field Extraction Tool):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"SourceName":"[^"]+/(?&amp;lt;PDF&amp;gt;[^/]+?\.pdf).*"userid":.+?,ou=(?&amp;lt;user_org&amp;gt;\w+),
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works on my development system with the example data you provided. It should produce the same results for you are using &lt;CODE&gt;props.conf&lt;/CODE&gt; file field extraction, but is easier to work with.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 16:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288994#M87478</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-02-16T16:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288995#M87479</link>
      <description>&lt;P&gt;try setting &lt;CODE&gt;INDEXED_VALUE = false&lt;/CODE&gt; in fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[user_org]
INDEXED_VALUE = false
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2018 17:10:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288995#M87479</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-16T17:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288996#M87480</link>
      <description>&lt;P&gt;I'm putting this separate because I was testing both answers from  &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt; and &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/120445"&gt;@cpetterborg&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;OK, I'm really confused:&lt;/P&gt;

&lt;P&gt;I used the suggestion from &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt; for user_org, restarted and performed my search.  No luck.  The field didn't show.  I verified it worked with rex field = _rex ......  and it worked there.&lt;/P&gt;

&lt;P&gt;Then I started working through what &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/120445"&gt;@cpetterborg&lt;/a&gt; said and opened up the Splunk UI Extraction Tool and it showed user_org as an existing field!  whaaa?  If it's an existing field, why doesn't it show up?&lt;/P&gt;

&lt;P&gt;I re-ran my search, and it still didn't show up.   I tried running my search with | stats count by user_org but still no results.  I clicked to open All Fields, in case it was hidden there but user_org wasn't listed.&lt;/P&gt;

&lt;P&gt;I then finished going through the Extraction Tool and saved (just in case I had not properly passed everything across my cluster).  I then tried searching again and nope, that field STILL doesn't show up anywhere. &lt;/P&gt;

&lt;P&gt;BUT, it still shows up when going through the Extraction Tool....&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288996#M87480</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2020-09-29T18:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288997#M87481</link>
      <description>&lt;P&gt;Try to run this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | extract reload=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then run it without &lt;CODE&gt;extract&lt;/CODE&gt; command. Sometimes that's required for Field extractions to show up.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 17:20:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288997#M87481</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-02-16T17:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288998#M87482</link>
      <description>&lt;P&gt;Are you in verbose mode in your search? if not, try that.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 17:22:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288998#M87482</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-02-16T17:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288999#M87483</link>
      <description>&lt;P&gt;I'm posting here because I used all three answers from @somesoni2 and @cpetterborg and @493669 to get things to work.&lt;/P&gt;

&lt;P&gt;@somesoni2's extractions ( although @cpetterborg version would have worked as well)&lt;BR /&gt;
@cpetterborg check via the Extraction Tool &lt;BR /&gt;
@493669 config change in fields.conf  &lt;/P&gt;

&lt;P&gt;Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 17:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/288999#M87483</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2018-02-16T17:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the regex work in search but not in props.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/289000#M87484</link>
      <description>&lt;P&gt;In my case what worked is the answer from @somesoni2 &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;your base search | extract reload=t&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Sometimes things does not update even if you reload splunk.&lt;BR /&gt;
Another fact about field extraction is that it takes some minutes for fields to show up, in this case just wait some minutes until you see the fields. &lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 11:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-regex-work-in-search-but-not-in-props-conf/m-p/289000#M87484</guid>
      <dc:creator>sonny_monti</dc:creator>
      <dc:date>2019-04-17T11:19:00Z</dc:date>
    </item>
  </channel>
</rss>

