<?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 How do I extract this field from my sample data using rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279215#M84314</link>
    <description>&lt;P&gt;Scenario:  I need to extract the &lt;STRONG&gt;User&lt;/STRONG&gt; out of the following field msg using rex. So, I need &lt;CODE&gt;abcdefg&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Group &amp;lt;XGroupPolicy&amp;gt; User &amp;lt;abcdefg&amp;gt; IP &amp;lt;192.168.0.1&amp;gt; SVC Message: 16/NOTICE: The user has requested to disconnect the connection.. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = main | rex field=msg [???]  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2016 20:12:40 GMT</pubDate>
    <dc:creator>packet_hunter</dc:creator>
    <dc:date>2016-06-02T20:12:40Z</dc:date>
    <item>
      <title>How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279215#M84314</link>
      <description>&lt;P&gt;Scenario:  I need to extract the &lt;STRONG&gt;User&lt;/STRONG&gt; out of the following field msg using rex. So, I need &lt;CODE&gt;abcdefg&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Group &amp;lt;XGroupPolicy&amp;gt; User &amp;lt;abcdefg&amp;gt; IP &amp;lt;192.168.0.1&amp;gt; SVC Message: 16/NOTICE: The user has requested to disconnect the connection.. 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = main | rex field=msg [???]  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279215#M84314</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279216#M84315</link>
      <description>&lt;P&gt;I don't see the value 'abcdefg' in the your sample data. Could you confirm which string from your sample data you need extracted?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:22:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279216#M84315</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-02T20:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279217#M84316</link>
      <description>&lt;P&gt;Assuming the text you want is the second "word" of msg, then this should do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=msg "\s(?&amp;lt;user&amp;gt;[^\s]*)\s" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You may want to get to know regex101.com.  It's a great way to experiment with regular expressions until you find what works.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279217#M84316</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-02T20:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279218#M84317</link>
      <description>&lt;P&gt;when I was pasting, the msg field it was not rendering, does it make sense now?&lt;BR /&gt;
abcdefg is a redacted username&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279218#M84317</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279219#M84318</link>
      <description>&lt;P&gt;Based on your comment, this answer is similar to the one for your previous question.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=msg "User (?&amp;lt;user&amp;gt;[^ ]*)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279219#M84318</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-02T20:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279220#M84319</link>
      <description>&lt;P&gt;Try this then&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index = main | rex field=msg "User\s+\&amp;lt;(?&amp;lt;User&amp;gt;[^\&amp;gt;]+)\&amp;gt;" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:28:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279220#M84319</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-02T20:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279221#M84320</link>
      <description>&lt;P&gt;Hi Packet Hunter,&lt;/P&gt;

&lt;P&gt;This probably is not the cleanest but here is how I would pull all the fields from that simultaneously.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype=blah 
| rex "Group\s&amp;lt;(?P&amp;lt;Group&amp;gt;\w+)&amp;gt;\sUser\s&amp;lt;(?P&amp;lt;User&amp;gt;\w+)&amp;gt;\sIP\s&amp;lt;(?P&amp;lt;IP_Address&amp;gt;\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})&amp;gt;\sSVC\sMessage:\s(?P&amp;lt;Message_Num&amp;gt;\d+)\/\w+:\s(?P&amp;lt;Message&amp;gt;(.*))" 
| table Group User IP_Address Message_Num Message
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279221#M84320</guid>
      <dc:creator>supabuck</dc:creator>
      <dc:date>2016-06-02T20:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279222#M84321</link>
      <description>&lt;P&gt;Thank you that works&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:31:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279222#M84321</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279223#M84322</link>
      <description>&lt;P&gt;Your code works partially - probably because my first paste did not render correctly and your code worked on that.   &lt;/P&gt;

&lt;P&gt;I appreciate your help and the refer to the link.   Yes REX is a hurdle for me.   &lt;/P&gt;

&lt;P&gt;This question is similar to the other you answered, however the msg field values are different which is why I asked for more help with a different rex.&lt;/P&gt;

&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:35:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279223#M84322</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279224#M84323</link>
      <description>&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '^(?P\w+)\s(?P\w+)\sIP\s&amp;lt;(?P\d{1': Regex: missing ) &lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279224#M84323</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279225#M84324</link>
      <description>&lt;P&gt;Thank you for your attempt I will study it for educational purposes&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:48:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279225#M84324</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-02T20:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279226#M84325</link>
      <description>&lt;P&gt;Sorry, I am pretty new to regex built within searches. What I usually do is copy a sample message and paste it into the TEST STRING at &lt;A href="https://regex101.com/"&gt;regex101.com&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;After  doing that you can work on building your regex and it will highlight the groups in real time!&lt;/P&gt;

&lt;P&gt;For searches to rex out result fields I usually will do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex sourcetype=jws | rex "^\d+\s+\w+\s\d+\s\d+:\d+:\d+,\d+\s(?P&amp;lt;value1&amp;gt;\w+)\s\[]\[]\[]\s\[(?P&amp;lt;value2&amp;gt;\w+)\]\s(?P&amp;lt;value3&amp;gt;(.*))\s\[]\[(.*)\n(?P&amp;lt;value3&amp;gt;(.*))" | table _time host  value1 value2 value3 value4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then if you want to do another search on the results for that you can add this onto the search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search value1="somevalue"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it will narrow down the results to only include it where value1="somevalue" in the resulting table.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 18:55:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279226#M84325</guid>
      <dc:creator>supabuck</dc:creator>
      <dc:date>2016-06-03T18:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract this field from my sample data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279227#M84326</link>
      <description>&lt;P&gt;thank you for the response&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 19:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-this-field-from-my-sample-data-using-rex/m-p/279227#M84326</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-06-03T19:53:35Z</dc:date>
    </item>
  </channel>
</rss>

