<?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: Match by rex field in subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488783#M136513</link>
    <description>&lt;P&gt;@jscraig2006 that shouldn't be a problem, because &lt;CODE&gt;log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | fields tid1&lt;/CODE&gt; does return results.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jan 2020 04:55:58 GMT</pubDate>
    <dc:creator>infcl</dc:creator>
    <dc:date>2020-01-18T04:55:58Z</dc:date>
    <item>
      <title>Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488779#M136509</link>
      <description>&lt;P&gt;I have one log like:&lt;BR /&gt;
&lt;CODE&gt;log1 tid=,"tid":"abcd";&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;And another log like:&lt;BR /&gt;
&lt;CODE&gt;log2 userid=11 tid=abcd&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I want to get the count of results where rexed tid in log1 matches tid in log2, deduped by userid.&lt;/P&gt;

&lt;P&gt;I tried:&lt;BR /&gt;
&lt;CODE&gt;log2 [search log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | eval tid1=tid | dedup userid] | stats count&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;However it returned 0. though there should be more. &lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 21:55:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488779#M136509</guid>
      <dc:creator>infcl</dc:creator>
      <dc:date>2020-01-17T21:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488780#M136510</link>
      <description>&lt;P&gt;i don't know if this will make a difference, but your regex is missing escapes on your some of your characters. Try &lt;CODE&gt;| rex "tid\"\:\"(?&amp;lt;tid1&amp;gt;[^\"]+)"&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 23:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488780#M136510</guid>
      <dc:creator>jscraig2006</dc:creator>
      <dc:date>2020-01-17T23:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488781#M136511</link>
      <description>&lt;P&gt;e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="userid=11 tid=abcd"
| appendpipe 
    [eval _raw="userid=12 tid=abce"]
| kv
| search
    [| makeresults 
    | eval _raw="tid=,\"tid\":\"abcd\";" 
    | rex field=_raw "\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" 
    | rename tid1 as query]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;log2 
| kv
| search [ search log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | rename tid1 as query] 
| stats count by userid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, @infcl&lt;BR /&gt;
maybe, log1 does not have &lt;CODE&gt;userid&lt;/CODE&gt;. so, &lt;CODE&gt;dedup userid&lt;/CODE&gt; can't works and result is "0"&lt;BR /&gt;
I don't know the fields extracted, I use &lt;CODE&gt;kv&lt;/CODE&gt;&lt;BR /&gt;
if log2 has the field &lt;CODE&gt;userid&lt;/CODE&gt; , &lt;CODE&gt;kv&lt;/CODE&gt; is not needed&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 02:02:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488781#M136511</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-18T02:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488782#M136512</link>
      <description>&lt;P&gt;Unfortunately it didn't work.&lt;/P&gt;

&lt;P&gt;log2 always has &lt;CODE&gt;userid&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Even &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   log2   
   | search [ search log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | rename tid1 as query]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;did not return any results.&lt;/P&gt;

&lt;P&gt;When I search &lt;CODE&gt;log2&lt;/CODE&gt; and &lt;CODE&gt;log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | fields tid1&lt;/CODE&gt; individually, they return results, so those portions are correct.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 04:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488782#M136512</guid>
      <dc:creator>infcl</dc:creator>
      <dc:date>2020-01-18T04:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488783#M136513</link>
      <description>&lt;P&gt;@jscraig2006 that shouldn't be a problem, because &lt;CODE&gt;log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | fields tid1&lt;/CODE&gt; does return results.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 04:55:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488783#M136513</guid>
      <dc:creator>infcl</dc:creator>
      <dc:date>2020-01-18T04:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488784#M136514</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;log2 "tid1 value"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;return results?&lt;/P&gt;

&lt;P&gt;my search is same logic search.&lt;/P&gt;

&lt;P&gt;I think you say&lt;BR /&gt;
search &lt;CODE&gt;log2&lt;/CODE&gt;⇨ returen results&lt;BR /&gt;
search &lt;CODE&gt;log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | fields tid1&lt;/CODE&gt;⇨ returen results&lt;BR /&gt;
OK?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 05:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488784#M136514</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-18T05:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488785#M136515</link>
      <description>&lt;P&gt;Yes that's what I mean, the individual searches are correct. But the matching is not.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 06:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488785#M136515</guid>
      <dc:creator>infcl</dc:creator>
      <dc:date>2020-01-18T06:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488786#M136516</link>
      <description>&lt;P&gt;If log2 &lt;CODE&gt;tid&lt;/CODE&gt; field is extracted,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;log2 [search log1 | rex field=_raw "tid=,\"tid\":\"(?&amp;lt;tid1&amp;gt;.*)\";" | fields tid1 |rename tid1 as tid]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query should return results.&lt;BR /&gt;
if is returns "0" , there really is no result.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 08:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488786#M136516</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-18T08:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Match by rex field in subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488787#M136517</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="YouShouldAlwaysSpecifyAnIndex" AND sourcetype="AndSourcetypeToo" AND ("log1" OR "log2")
| rex "tid=,\"tid\":\"(?&amp;lt;tid&amp;gt;.*)\";"
| eval which=if(searchmatch("log1"), "log1", "log2")
| dedup userid which
| stats dc(which) AS which_count BY tid
| where which_count==2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jan 2020 19:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Match-by-rex-field-in-subsearch/m-p/488787#M136517</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-01-18T19:43:36Z</dc:date>
    </item>
  </channel>
</rss>

