<?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 extract these fields from my data using rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249975#M74621</link>
    <description>&lt;P&gt;Yes, it speeds up search and offloads the indexers from having to perform line-breaking and timestamp recognition tasks too.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2015 11:58:55 GMT</pubDate>
    <dc:creator>dmaislin_splunk</dc:creator>
    <dc:date>2015-09-30T11:58:55Z</dc:date>
    <item>
      <title>How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249968#M74614</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I wonder whether someone could help me please.&lt;/P&gt;

&lt;P&gt;I have a field called detail.cid-repsonse which looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[{"name":{"current":{"firstName":"JOHN","lastName":"SMITH"}},"ids":{"sut":"1234567890","nino":"AA111111A"},"dateOfBirth":"26121973"}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From this I need to create new fields and extract the following data:&lt;/P&gt;

&lt;P&gt;First Name&lt;BR /&gt;
Last Name&lt;BR /&gt;
Sut&lt;BR /&gt;
NINO&lt;BR /&gt;
DOB&lt;/P&gt;

&lt;P&gt;I just wondered whether someone may be able to offer some guidance on how I may go about this please.&lt;/P&gt;

&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 08:25:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249968#M74614</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-09-30T08:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249969#M74615</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you simply can do this with the rex command. You can restrict the rex command to one field with the field parameter. Here an example for the first name:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field="detail.cid-repsonse" "\"firstName\":\"(?&amp;lt;firstName&amp;gt;[^\"]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I created a user everywhere example, which means, you can copy the follwoing search and paste it to your splunk search line and it will work. This can give you an idea how things work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval "detail.cid-repsonse"="[{\"name\":{\"current\":{\"firstName\":\"JOHN\",\"lastName\":\"SMITH\"}},\"ids\":{\"sut\":\"1234567890\",\"nino\":\"AA111111A\"},\"dateOfBirth\":\"26121973\"}]" | rex field="detail.cid-repsonse" "\"firstName\":\"(?&amp;lt;firstName&amp;gt;[^\"]+)" | rex field="detail.cid-repsonse" "\"lastName\":\"(?&amp;lt;lastName&amp;gt;[^\"]+)" | rex field="detail.cid-repsonse" "\"sut\":\"(?&amp;lt;sut&amp;gt;[^\"]+)" | table "detail.cid-repsonse" firstName lastName sut
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By the way, it looks like you have valid json in your field, so you might also be able to use the spath command: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.5/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In your case just append this to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath input="detail.cid-repsonse"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and you will get new fields with your needed data.&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 09:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249969#M74615</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-09-30T09:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249970#M74616</link>
      <description>&lt;P&gt;Hi Tom, this is great and works a treat.&lt;/P&gt;

&lt;P&gt;Thank you for taking the time to reply to my post.&lt;/P&gt;

&lt;P&gt;Kind Regards and thanks&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:20:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249970#M74616</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-09-30T11:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249971#M74617</link>
      <description>&lt;P&gt;Just use this technique:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.2/Data/Extractfieldsfromfileheadersatindextime"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.2/Data/Extractfieldsfromfileheadersatindextime&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Forwarder props.conf entry for the specific sourcetype.&lt;BR /&gt;
INDEXED_EXTRACTIONS=JSON&lt;/P&gt;

&lt;P&gt;Fields are fed to indexers from the forwarder and searches will be much faster as a result.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249971#M74617</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2015-09-30T11:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249972#M74618</link>
      <description>&lt;P&gt;Hi @dmaislin, thank you for taking the time to reply to my post. I'm very new to Splunk, so your solution may be a little over my head, but I really appreciate you highlighting something which I will no doubt be able to use in the future.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:50:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249972#M74618</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2015-09-30T11:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249973#M74619</link>
      <description>&lt;P&gt;I think he does not have json only. Just the field he mentioned in his questions is json. If the complete event is json, your anser might be the even better option.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249973#M74619</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-09-30T11:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249974#M74620</link>
      <description>&lt;P&gt;No problem.  If the logged events are JSON, this technique is probably the simplest approach as all of your fields will be present without requiring any extra field extraction work.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249974#M74620</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2015-09-30T11:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract these fields from my data using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249975#M74621</link>
      <description>&lt;P&gt;Yes, it speeds up search and offloads the indexers from having to perform line-breaking and timestamp recognition tasks too.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 11:58:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-these-fields-from-my-data-using-rex/m-p/249975#M74621</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2015-09-30T11:58:55Z</dc:date>
    </item>
  </channel>
</rss>

