<?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: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389850#M113583</link>
    <description>&lt;P&gt;@charlesxavier For example your index name is test, your query would be-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test| rex _raw "\"phoneNumber\":\"(?&amp;lt;phoneNumber&amp;gt;[^\"]+)"  | rex field=_raw "\"Number\":\"(?&amp;lt;CustomerNumber&amp;gt;[^\"]+)" | stats values(CustomerNumber) as CustomerNumber by phoneNumber
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Feb 2019 19:32:33 GMT</pubDate>
    <dc:creator>Vijeta</dc:creator>
    <dc:date>2019-02-15T19:32:33Z</dc:date>
    <item>
      <title>Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389847#M113580</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I'm trying to extract a customer number by having two searches pull web service calls and compare one field with the same values, then get the customer number from the subsearch. The reason for doing this with two web calls is because one is vital for determining if a user was created, but it does not contain the customer number, the second call carries the number.&lt;/P&gt;

&lt;P&gt;Here's an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;addCustomer call:
customer: {"Number":"","FirstName":"Foo","LastName":"Bar","phoneNumber":"1234567890"}

secondCall:
customer: {"Number":"12345676","FirstName":"Foo","LastName":"Bar","phoneNumber":"1234567890"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wanted to compare a field that is unique to this user, like the phone number or email (sometimes there isn't an email) and if they are matched, I wanted to get the Number in the second call (which is the subsearch).&lt;/P&gt;

&lt;P&gt;Here's what I have to get both web calls for all users within a set time frame: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"addCustomer"
| rex field=_raw "\"phoneNumber\":\"(?&amp;lt;phoneNum&amp;gt;[^\"]+)"  
| append [search "secondCall:" | rex field=_raw "\"Number\":\"(?&amp;lt;CustomerNumber&amp;gt;^\"]+)" | rex field=_raw "\"phoneNumber\":\"(?&amp;lt;phoneNum&amp;gt;[^\"]+)" ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm relatively new to Splunk, so any help would be appreciated! &lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 18:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389847#M113580</guid>
      <dc:creator>charlesxavier</dc:creator>
      <dc:date>2019-02-15T18:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389848#M113581</link>
      <description>&lt;P&gt;are you searching from same index ? how does your event data look like?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:18:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389848#M113581</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-15T19:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389849#M113582</link>
      <description>&lt;P&gt;Hi, yes I am searching from the same index and the event data looks like those two example calls I provided. &lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389849#M113582</guid>
      <dc:creator>charlesxavier</dc:creator>
      <dc:date>2019-02-15T19:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389850#M113583</link>
      <description>&lt;P&gt;@charlesxavier For example your index name is test, your query would be-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test| rex _raw "\"phoneNumber\":\"(?&amp;lt;phoneNumber&amp;gt;[^\"]+)"  | rex field=_raw "\"Number\":\"(?&amp;lt;CustomerNumber&amp;gt;[^\"]+)" | stats values(CustomerNumber) as CustomerNumber by phoneNumber
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389850#M113583</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-15T19:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389851#M113584</link>
      <description>&lt;P&gt;so from the query you have posted, you have already done the hard work. Now you just need to do something like this to join the events together: &lt;CODE&gt;|stats latest(*) as * by phoneNumber&lt;/CODE&gt; or &lt;CODE&gt;|stats values(*) as * by phoneNumber&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;All the best.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 19:37:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389851#M113584</guid>
      <dc:creator>chrisyounger</dc:creator>
      <dc:date>2019-02-15T19:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389852#M113585</link>
      <description>&lt;P&gt;Hi Chrisyoungerjds,&lt;/P&gt;

&lt;P&gt;I've tried adding in both of those lines, and I don't get any results found. Would coalesce() be alright to use here? Also, would I need to pass the second phone number from the subsearch to use to compare/join the events?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 12:50:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389852#M113585</guid>
      <dc:creator>charlesxavier</dc:creator>
      <dc:date>2019-02-18T12:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389853#M113586</link>
      <description>&lt;P&gt;@charlesxavier Did you try the above search, what output do you get?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 17:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389853#M113586</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-18T17:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389854#M113587</link>
      <description>&lt;P&gt;Hello, I tried using this and received the following:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex '"phoneNumber":"(?[^"]+)': Regex: unrecognized character after (? or (?-&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 17:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389854#M113587</guid>
      <dc:creator>charlesxavier</dc:creator>
      <dc:date>2019-02-18T17:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389855#M113588</link>
      <description>&lt;P&gt;@charlesxavier Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=test| rex _raw "\"phoneNumber\":\"(?&amp;lt;phoneNumber&amp;gt;\S+)}"  | rex field=_raw "\"Number\":\"(?&amp;lt;CustomerNumber&amp;gt;\S+)," | stats values(CustomerNumber) as CustomerNumber by phoneNumber
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Feb 2019 17:56:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389855#M113588</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-18T17:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can I extract a field from a subsearch by comparing two fields in both the search and subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389856#M113589</link>
      <description>&lt;P&gt;That seemed to do the trick, thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 18:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-extract-a-field-from-a-subsearch-by-comparing-two-fields/m-p/389856#M113589</guid>
      <dc:creator>charlesxavier</dc:creator>
      <dc:date>2019-02-18T18:58:13Z</dc:date>
    </item>
  </channel>
</rss>

