<?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 to replace join in below query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533251#M150663</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229747"&gt;@priyastalin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The general idea behind removing a join from a search is to combine the two search fragments to a single search separated by OR, e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*)) OR
(index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 )
...
then do stuff with the two data sets using eval/stats/...&lt;/LI-CODE&gt;&lt;P&gt;however, in your example, if you are just using the join to filter on groupId as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/23295"&gt;@nickhills&lt;/a&gt;&amp;nbsp;suggests, there are other options, but to achieve a similar outcome to the filtering join you could do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*)) OR
(index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 )
| stats values(groupId) as groupIds values(physicalElementId) as physicalElementIds by deviceId
| where mvcount(groupIds)=1
| stats dc(physicalElementIds) as Devices&lt;/LI-CODE&gt;&lt;P&gt;which would search both data sets, then aggregate the two data sets retaining the groupIds by deviceId and the subsequent where clause performs the filter, as all deviceIds that have no corresponding groupId will be removed (effective inner join).&lt;/P&gt;&lt;P&gt;Then your final stats will just get the unique&amp;nbsp;physicalElementId count.&lt;/P&gt;&lt;P&gt;Remember in Splunk that subsearches often come with limitations and performance implications and it is often useful to consider how a subsearch can be replaced with an alternative construct, like others have suggested here. It will generally come down to your data.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Dec 2020 22:52:55 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2020-12-15T22:52:55Z</dc:date>
    <item>
      <title>How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533131#M150625</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;could you please help me in replacing the join in below query?&lt;/P&gt;&lt;P&gt;index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*) | fields physicalElementId deviceId&lt;BR /&gt;| join deviceId [ search index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 | fields deviceId ]&lt;BR /&gt;| stats dc(physicalElementId) as Devices&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 12:55:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533131#M150625</guid>
      <dc:creator>priyastalin</dc:creator>
      <dc:date>2020-12-15T12:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533141#M150631</link>
      <description>&lt;P&gt;It might help if you can also post the contents of the macro&amp;nbsp;&lt;SPAN&gt;last_np_sourcetype()&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 13:35:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533141#M150631</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-12-15T13:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533149#M150634</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Content of first query &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*) | fields physicalElementId deviceId "&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This query has 39718 events&amp;nbsp; similarly like below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;"chassisName&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;10.241.241.22&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;cpyKey&lt;/SPAN&gt;: &lt;SPAN class="t number"&gt;168347&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;deviceId&lt;/SPAN&gt;: &lt;SPAN class="t number"&gt;19206245&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;deviceName&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;10.241.241.22&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;hwRev&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;installedFlash&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;installedMemory&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;pcb&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;pcbRev&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;physicalElementId&lt;/SPAN&gt;: &lt;SPAN class="t number"&gt;388725541&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;physicalSubType&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;physicalType&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;Power Supply&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;productFamily&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;Catalyst 2K/3K Series Power Supplies&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;productId&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;PWR-C1-1100WAC&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;productType&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;Power Supplies&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;serialNumber&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;DTN2246V1S4&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;serialNumberStatus&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;UNKNOWN&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;slot&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;PWRSPPLY2&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;swVersion&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;tan&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;tanRev&lt;/SPAN&gt;: &lt;SPAN class="t null"&gt;null&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;timeStamp&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;2020-12-14T13:35:46"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Content of second query:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;"index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 | fields deviceId"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;This query has 25 events similarly like below&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="json-event  wrap "&gt;&lt;DIV class="json-tree shared-jsontree"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt; &lt;A href="https://sandbox-bci.cisco.com:8000/en-US/app/Hardware_Planning/search?earliest=%40mon&amp;amp;latest=now&amp;amp;q=search%20index%3D168347-np%20%5B%7C%20%60last_np_sourcetype(%20%22index%3D168347-np%22%2C%20%22group_members%22)%60%20%5D%20groupId%3D290681%20%7C%20fields%20deviceId&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=events&amp;amp;display.page.search.tab=events&amp;amp;sid=1608040474.330736#" target="_blank" rel="noopener"&gt;[-]&lt;/A&gt; &lt;SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;deviceId&lt;/SPAN&gt;: &lt;SPAN class="t number"&gt;16681845&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;groupId&lt;/SPAN&gt;: &lt;SPAN class="t number"&gt;290681&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;groupName&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;ASR 1K Routers&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="key level-1"&gt;&lt;SPAN class="key-name"&gt;timeStamp&lt;/SPAN&gt;: &lt;SPAN class="t string"&gt;2020-12-14T13:35:27&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="json-tree shared-jsontree"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="json-tree shared-jsontree"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="json-tree shared-jsontree"&gt;&lt;STRONG&gt;Final output is:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="json-tree shared-jsontree"&gt;&lt;SPAN&gt;210&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 15 Dec 2020 13:58:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533149#M150634</guid>
      <dc:creator>priyastalin</dc:creator>
      <dc:date>2020-12-15T13:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533153#M150638</link>
      <description>&lt;P&gt;What's the point of this query?&amp;nbsp; It's joining a single field to events that already have that field so what value is added?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 14:02:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533153#M150638</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-12-15T14:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533173#M150648</link>
      <description>&lt;P&gt;I think (&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229747"&gt;@priyastalin&lt;/a&gt;&amp;nbsp;correct me if wrong) it looks like this is just so you can filter on the groupId?&lt;/P&gt;&lt;P&gt;I'm not sure if seeing the contents of the macro would help to understand if its doing a simple filter or if there is something more complex going on to get the set of results.&lt;/P&gt;&lt;P&gt;If this is something you run frequently, I think a lookup might be a far simpler (and faster) approach.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 15:24:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533173#M150648</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-12-15T15:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace join in below query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533251#M150663</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229747"&gt;@priyastalin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The general idea behind removing a join from a search is to combine the two search fragments to a single search separated by OR, e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*)) OR
(index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 )
...
then do stuff with the two data sets using eval/stats/...&lt;/LI-CODE&gt;&lt;P&gt;however, in your example, if you are just using the join to filter on groupId as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/23295"&gt;@nickhills&lt;/a&gt;&amp;nbsp;suggests, there are other options, but to achieve a similar outcome to the filtering join you could do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=168347-np [ | `last_np_sourcetype("index=168347-np","hardware")`] (physicalType=*)) OR
(index=168347-np [| `last_np_sourcetype( "index=168347-np", "group_members")` ] groupId=290681 )
| stats values(groupId) as groupIds values(physicalElementId) as physicalElementIds by deviceId
| where mvcount(groupIds)=1
| stats dc(physicalElementIds) as Devices&lt;/LI-CODE&gt;&lt;P&gt;which would search both data sets, then aggregate the two data sets retaining the groupIds by deviceId and the subsequent where clause performs the filter, as all deviceIds that have no corresponding groupId will be removed (effective inner join).&lt;/P&gt;&lt;P&gt;Then your final stats will just get the unique&amp;nbsp;physicalElementId count.&lt;/P&gt;&lt;P&gt;Remember in Splunk that subsearches often come with limitations and performance implications and it is often useful to consider how a subsearch can be replaced with an alternative construct, like others have suggested here. It will generally come down to your data.&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 22:52:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-join-in-below-query/m-p/533251#M150663</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-12-15T22:52:55Z</dc:date>
    </item>
  </channel>
</rss>

