<?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: extract fields from rex _raw in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348729#M170231</link>
    <description>&lt;P&gt;@oustinov, I am surprised as to how your first code is working. Ideally you are supposed to escape backslashes in regular expression with a forward slash. Following is how your second query should look like. You should also try to test regular expressions on regex101.com&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search sourcetype=apache "/apps/public/v4/client1/local/"
| rex "\/apps\/public\/v4\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try the following run anywhere search for testing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="/apps/public/v4/client1/local/"
| rex "\/apps\/public\/v4\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 Apr 2018 18:08:05 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-04-18T18:08:05Z</dc:date>
    <item>
      <title>extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348726#M170228</link>
      <description>&lt;P&gt;trying to extract a fields from logfile's text (have both examples in logfile):&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search sourcetype=apache "/apps/public/client1/local/" | "rex field=_raw "/apps/public/(?&amp;lt;client&amp;gt;\w+)/(?&amp;lt;region&amp;gt;\w+)/""&lt;/CODE&gt; - works perfect, i see a fields "client" and "region" with correct client names&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search sourcetype=apache "/apps/public/v4/client1/local/" | "rex field=_raw "/apps/public/v4/(?&amp;lt;client&amp;gt;\w+)/(?&amp;lt;region&amp;gt;\w+)/""&lt;/CODE&gt; - does not work - no fields "client" and "region"&lt;/P&gt;

&lt;P&gt;why and what is wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 15:29:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348726#M170228</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-18T15:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348727#M170229</link>
      <description>&lt;P&gt;Can you edit this and wrap the middle two lines with the code button (or single backticks, if you can't get the code button to work for you)? The formatter is eating some of your rex, which makes it harder to diagnose!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 16:54:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348727#M170229</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-18T16:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348728#M170230</link>
      <description>&lt;P&gt;Are you very sure this is how you entered them? What are those &lt;CODE&gt;"&lt;/CODE&gt; doing before &lt;CODE&gt;rex&lt;/CODE&gt; and at the end of the line? Are you sure you actually typed those into the search bar for both attempts?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 17:43:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348728#M170230</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-04-18T17:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348729#M170231</link>
      <description>&lt;P&gt;@oustinov, I am surprised as to how your first code is working. Ideally you are supposed to escape backslashes in regular expression with a forward slash. Following is how your second query should look like. You should also try to test regular expressions on regex101.com&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search sourcetype=apache "/apps/public/v4/client1/local/"
| rex "\/apps\/public\/v4\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try the following run anywhere search for testing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="/apps/public/v4/client1/local/"
| rex "\/apps\/public\/v4\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)\/"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Apr 2018 18:08:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348729#M170231</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-18T18:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348730#M170232</link>
      <description>&lt;P&gt;sorry " before rex is a typo&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 20:37:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348730#M170232</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-18T20:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348731#M170233</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
thanks for answer, but... 1st (without "/v4/") works in both variants, 2nd - same result - no fields extracted &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search sourcetype=apache  "/apps/public/v4/*" | rex field=_raw "/apps/public/v4/(?&amp;lt;client&amp;gt;\w+)/(?&amp;lt;region&amp;gt;\w+)/"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It finds all entries with "/apps/public/v4/"  but does not extract fields at all. by delete /v4/ - it put "v4" as a client name &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
does splunk have any restrictions on "v4"? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 20:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348731#M170233</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-18T20:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348732#M170234</link>
      <description>&lt;P&gt;Did you check out the run anywhere search. If the run anywhere search is working but not with your raw data may be the pattern is different than what you have provided. Add some sample of raw events in the case. Mock/anonymize any sensitive data from the event keeping the pattern similar to what is present.&lt;/P&gt;

&lt;P&gt;Does both URL v4 and non-v4 end with region? or is there any content after region. Is the URL followed by Space or Double Quotes or any other pattern?&lt;/P&gt;

&lt;P&gt;Please add some samples.&lt;/P&gt;

&lt;P&gt;Since the provided answer did not work as expected I have converted my answer to comment. So that other community experts can also look at this unanswered question and reply.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 03:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348732#M170234</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-19T03:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348733#M170235</link>
      <description>&lt;P&gt;Can you try below regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\/apps\/public\/*\w*\d*\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)\/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 04:13:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348733#M170235</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-04-19T04:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348734#M170236</link>
      <description>&lt;P&gt;it does not work - it take v4 as a client &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 10:39:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348734#M170236</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-19T10:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348735#M170237</link>
      <description>&lt;P&gt;Give this a shot:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search sourcetype=apache "/apps/public/client1/local/" OR "/apps/public/v4/client1/local/"
| rex "\/apps\/public(\/v4)?\/(?&amp;lt;client&amp;gt;[^\/]+)\/(?&amp;lt;region&amp;gt;[^\/]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should ignore v4 if present but still allow it to work on URLs that do not contain v4. If you need it more generic, please share some examples where it fails, and I can help you iterate.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 14:22:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348735#M170237</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-19T14:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348736#M170238</link>
      <description>&lt;P&gt;Exact your rex does not work, but this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "\/apps\/public(\/v4)?\/(?&amp;lt;client&amp;gt;\w+)\/(?&amp;lt;region&amp;gt;\w+)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;works perfect! &lt;BR /&gt;
Many thanks!!!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 15:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348736#M170238</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-19T15:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: extract fields from rex _raw</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348737#M170239</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
this does not work, please see answer above - this works 100%&lt;BR /&gt;
thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 07:20:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-fields-from-rex-raw/m-p/348737#M170239</guid>
      <dc:creator>oustinov</dc:creator>
      <dc:date>2018-04-20T07:20:09Z</dc:date>
    </item>
  </channel>
</rss>

