<?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: Extracting values from a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257333#M77064</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex field=abcd "=\[type=(?&amp;lt;new_type&amp;gt;.*?)\]"
| stats count by new_type
| rename new_type as type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you a field named "new_type." It is best if you pick a different field name, otherwise Splunk will merge all the field definitions.  I renamed it at the end. This also assumes that what you want is part of the existing field "abcd".&lt;/P&gt;</description>
    <pubDate>Wed, 23 Mar 2016 00:25:06 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2016-03-23T00:25:06Z</dc:date>
    <item>
      <title>Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257332#M77063</link>
      <description>&lt;P&gt;I have 2 fields like these:&lt;/P&gt;

&lt;P&gt;For Field 1:&lt;BR /&gt;
type=Intelligence&lt;/P&gt;

&lt;P&gt;Field 2:&lt;BR /&gt;
[abcd=[type=High] [Number=3309934] ]&lt;/P&gt;

&lt;P&gt;I know I can search by type but there is another field named also named type so if I do&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ...stats count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would get:&lt;/P&gt;

&lt;P&gt;Intelligence&lt;/P&gt;

&lt;P&gt;How do I specifically extract High from Field 2 (Typing High in the search is not an option because you could have type=Small&lt;/P&gt;

&lt;P&gt;Also, using this code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ...stats count by abcd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;produces : type=High&lt;/P&gt;

&lt;P&gt;I only want to see High and not "type="&lt;BR /&gt;
If you can provide a workable solution either using rex and eval or another code, it would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 22:39:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257332#M77063</guid>
      <dc:creator>ibekacyril</dc:creator>
      <dc:date>2016-03-22T22:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257333#M77064</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex field=abcd "=\[type=(?&amp;lt;new_type&amp;gt;.*?)\]"
| stats count by new_type
| rename new_type as type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you a field named "new_type." It is best if you pick a different field name, otherwise Splunk will merge all the field definitions.  I renamed it at the end. This also assumes that what you want is part of the existing field "abcd".&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 00:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257333#M77064</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-03-23T00:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257334#M77065</link>
      <description>&lt;P&gt;If the above doesn't work, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; yoursearchhere
 | rex  "=\[type=(?&amp;lt;new_type&amp;gt;.*?)\]"
 | stats count by new_type
 | rename new_type as type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; yoursearchhere
 | rex  "\=\[type\=(?&amp;lt;new_type&amp;gt;.*?)\]"
 | stats count by new_type
 | rename new_type as type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did make typo in the original answer, which I have now fixed. It is &lt;CODE&gt;stats&lt;/CODE&gt; not &lt;CODE&gt;stat&lt;/CODE&gt;! I still don't see anything wrong witn the original regular expression, but maybe someone else will...&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 16:09:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257334#M77065</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-03-23T16:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257335#M77066</link>
      <description>&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2016 01:26:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257335#M77066</guid>
      <dc:creator>ibekacyril</dc:creator>
      <dc:date>2016-03-24T01:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257336#M77067</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
try this search code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;............................. | rex  field=_raw  "/[abcd/=/[type/=(?&amp;lt;Type&amp;gt;[^\/]]+)" | stats count by Type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2016 13:13:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257336#M77067</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-03-24T13:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257337#M77068</link>
      <description>&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2016 19:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-values-from-a-field/m-p/257337#M77068</guid>
      <dc:creator>ibekacyril</dc:creator>
      <dc:date>2016-04-01T19:21:40Z</dc:date>
    </item>
  </channel>
</rss>

