<?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: Join with rex not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628429#M218282</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;this is the regex to extract the fields you need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;that you can test at&amp;nbsp;&lt;A href="https://regex101.com/r/EsHXQv/1" target="_blank"&gt;https://regex101.com/r/EsHXQv/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;About the join, you have two solutions that depends on the number of results of the second search:&lt;/P&gt;&lt;P&gt;if in the second search (index=bcz field5="name") you have more than 50,000 results, you can use the stats command, applying something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc OR (index=bcz field5="name")
| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"
| eval key=coalesce(field1,field7)
| stats 
   dc(index) AS index_count 
   values(field2) AS field2
   values(field3) AS field3
   BY key
| where index_count=2&lt;/LI-CODE&gt;&lt;P&gt;if instead you have less than 50,000 results, you can use a subsearch:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc 
| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"
| search [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]
| table field1 field2 field3&lt;/LI-CODE&gt;&lt;P&gt;If you create a field extraction for field 1, you can also use a simpler search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]
| table field1 field2 field3&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2023 08:49:57 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-01-26T08:49:57Z</dc:date>
    <item>
      <title>How to join with rex not working?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628418#M218276</link>
      <description>&lt;P&gt;I have 2 index, abc and bcz&lt;/P&gt;
&lt;P&gt;index abc data is in raw format like below.&lt;/P&gt;
&lt;P&gt;&amp;lt;random ip address&amp;gt;|-NA\CAPITA|5xxhxh545|jljdjhsdhj78987|hkjhkdjfkjfd5672v2hg7|87675678vf6x_&lt;BR /&gt;&amp;lt;random date time&amp;gt; "GET http:\\at-abc.com http/1.1" 500 &amp;lt;random values&amp;gt;&lt;/P&gt;
&lt;P&gt;I want to pull 87675678vf6x_ as field1 at-abc.com as field2 and 500 as field3.&lt;/P&gt;
&lt;P&gt;index bcz got formatted data.&lt;/P&gt;
&lt;P&gt;I now want to compare both indexes with field 1 of index abc with another field7 in bcz where bcz field5="name"&lt;BR /&gt;and return field1 field2 and field3.&lt;/P&gt;
&lt;P&gt;It looks simple but not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 19:15:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628418#M218276</guid>
      <dc:creator>harryhcg</dc:creator>
      <dc:date>2023-01-26T19:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Join with rex not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628421#M218278</link>
      <description>&lt;P&gt;The first thing you need to do is to explain "not working". (Really, try to avoid this meaningless phrase at all cost.) &amp;nbsp;What have you tried? &amp;nbsp;What is the output? &amp;nbsp;What is the desired or "correct" output? &amp;nbsp;How do the two output differ? You mentioned field1, field2, field3, field5, field7. &amp;nbsp;Is there any significance in field4, field6? (Also, even though I can understand the desire to anonymize raw data, spelling a URL as http:\\ is bad practice.)&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 05:58:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628421#M218278</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-01-26T05:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Join with rex not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628429#M218282</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;this is the regex to extract the fields you need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;that you can test at&amp;nbsp;&lt;A href="https://regex101.com/r/EsHXQv/1" target="_blank"&gt;https://regex101.com/r/EsHXQv/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;About the join, you have two solutions that depends on the number of results of the second search:&lt;/P&gt;&lt;P&gt;if in the second search (index=bcz field5="name") you have more than 50,000 results, you can use the stats command, applying something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc OR (index=bcz field5="name")
| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"
| eval key=coalesce(field1,field7)
| stats 
   dc(index) AS index_count 
   values(field2) AS field2
   values(field3) AS field3
   BY key
| where index_count=2&lt;/LI-CODE&gt;&lt;P&gt;if instead you have less than 50,000 results, you can use a subsearch:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc 
| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"
| search [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]
| table field1 field2 field3&lt;/LI-CODE&gt;&lt;P&gt;If you create a field extraction for field 1, you can also use a simpler search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=abc [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]
| table field1 field2 field3&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 08:49:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628429#M218282</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-01-26T08:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Join with rex not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628444#M218285</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;Thank you for giving time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help to guide why used search twice? Apologies that not shared earlier but I had similar query with search keyword once and was not giving result.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;index=abc | rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"| search [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]| table field1 field2 field3index=abc 
| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"
| search [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]
| table field1 field2 field3&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting the result now but have some issue with count which is not corelating with another query result. Hope not duplicating something.&amp;nbsp; The other query is similar and based on index bcz and bda.&lt;BR /&gt;&lt;BR /&gt;For current query output I used&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=abc&lt;BR /&gt;| rex "(?ms)^([^\|]+\|){5}(?&amp;lt;field1&amp;gt;\w+).*\"GET\s+(http|https):\\\\(?&amp;lt;field2&amp;gt;[^\/]+)[^\"]+\"\s+(?&amp;lt;field3&amp;gt;\d+)"&lt;BR /&gt;| search [ search index=bcz field5="name" | rename field7 AS field1 | fields field1 ]&lt;/P&gt;&lt;P&gt;| dedup field1, field3&lt;BR /&gt;| stats count by field3&lt;BR /&gt;&lt;BR /&gt;@Anonymous&amp;nbsp;&amp;nbsp;field2, 4 and 6 I kept like that and will use on actual result. Trying to fix my errors with expert guidance, get correct logic of my silly mistakes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 10:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628444#M218285</guid>
      <dc:creator>harryhcg</dc:creator>
      <dc:date>2023-01-26T10:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join with rex not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628446#M218286</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you use dedup before a stats command, you'll never have correct results!&lt;/P&gt;&lt;P&gt;Try without dedup.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 11:33:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/628446#M218286</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-01-26T11:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Join with rex not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/629451#M218658</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253194"&gt;@harryhcg&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 07:31:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-join-with-rex-not-working/m-p/629451#M218658</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-02-03T07:31:27Z</dc:date>
    </item>
  </channel>
</rss>

