<?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: Left Outer Join in Splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665605#M228360</link>
    <description>&lt;P&gt;For your requirement, left join may not be ideal. Try this alternate implementation (replace make results query with your lookup/data query):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval DatabaseName=split("A B C"," ") | mvexpand DatabaseName | table DatabaseName | eval from="Lookup" | append [| makeresults | eval DatabaseName=split("A	A1	10#A	A2	20#C	C1	40#C	C2	50#D	D	60","#") | mvexpand DatabaseName | table DatabaseName | rex field=DatabaseName "^(?&amp;lt;DatabaseName&amp;gt;\S+)\s+(?&amp;lt;Instance&amp;gt;\S+)\s+(?&amp;lt;CPUUtilization&amp;gt;\S+)$" | eval from="search"] | eventstats values(from) as from by DatabaseName | where isnotnull(mvfilter(match(from,"Lookup"))) | foreach CPUUtilization Instance [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=coalesce('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',if(mvcount(from)=1 AND from="Lookup","NULL",null()))] | stats count by DatabaseName CPUUtilization Instance | table DatabaseName CPUUtilization Instance&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 19 Oct 2023 19:19:50 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2023-10-19T19:19:50Z</dc:date>
    <item>
      <title>Left Outer Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665592#M228358</link>
      <description>&lt;P&gt;Below is our Requirement&lt;/P&gt;&lt;P&gt;Lookup file has just one column DatabaseName, this is the left dataset&lt;/P&gt;&lt;TABLE width="100"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100"&gt;DatabaseName&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Search is for metrics on databases and ha&lt;/P&gt;&lt;P&gt;s multiple rows, this is the right dataset&lt;/P&gt;&lt;TABLE width="310px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;DatabaseName&lt;/TD&gt;&lt;TD width="72.8958px"&gt;Instance&lt;/TD&gt;&lt;TD width="115.083px"&gt;CPUUtilization&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;A&lt;/TD&gt;&lt;TD width="72.8958px"&gt;A1&lt;/TD&gt;&lt;TD width="115.083px"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;A&lt;/TD&gt;&lt;TD width="72.8958px"&gt;A2&lt;/TD&gt;&lt;TD width="115.083px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;C&lt;/TD&gt;&lt;TD width="72.8958px"&gt;C1&lt;/TD&gt;&lt;TD width="115.083px"&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;C&lt;/TD&gt;&lt;TD width="72.8958px"&gt;C2&lt;/TD&gt;&lt;TD width="115.083px"&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;D&lt;/TD&gt;&lt;TD width="72.8958px"&gt;D&lt;/TD&gt;&lt;TD width="115.083px"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Result is this after left join&lt;/P&gt;&lt;TABLE width="308px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;DatabaseName&lt;/TD&gt;&lt;TD width="72.8958px"&gt;Instance&lt;/TD&gt;&lt;TD width="115.083px"&gt;CPUUtilization&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;A&lt;/TD&gt;&lt;TD width="72.8958px"&gt;A1&lt;/TD&gt;&lt;TD width="115.083px"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;A&lt;/TD&gt;&lt;TD width="72.8958px"&gt;A2&lt;/TD&gt;&lt;TD width="115.083px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;B&lt;/TD&gt;&lt;TD width="72.8958px"&gt;NULL&lt;/TD&gt;&lt;TD width="115.083px"&gt;NULL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;C&lt;/TD&gt;&lt;TD width="72.8958px"&gt;C1&lt;/TD&gt;&lt;TD width="115.083px"&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="121.906px"&gt;C&lt;/TD&gt;&lt;TD width="72.8958px"&gt;C2&lt;/TD&gt;&lt;TD width="115.083px"&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I join using DatabaseName, I am getting only three records, 1 for A, 1 for B with NULL and 1 for C&lt;/P&gt;&lt;P&gt;My background is SQL and for me left join is all from left data set and all matching from right data set. So please suggest me how I can achive this.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 18:30:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665592#M228358</guid>
      <dc:creator>yaswanth1992</dc:creator>
      <dc:date>2023-10-19T18:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Left Outer Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665605#M228360</link>
      <description>&lt;P&gt;For your requirement, left join may not be ideal. Try this alternate implementation (replace make results query with your lookup/data query):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval DatabaseName=split("A B C"," ") | mvexpand DatabaseName | table DatabaseName | eval from="Lookup" | append [| makeresults | eval DatabaseName=split("A	A1	10#A	A2	20#C	C1	40#C	C2	50#D	D	60","#") | mvexpand DatabaseName | table DatabaseName | rex field=DatabaseName "^(?&amp;lt;DatabaseName&amp;gt;\S+)\s+(?&amp;lt;Instance&amp;gt;\S+)\s+(?&amp;lt;CPUUtilization&amp;gt;\S+)$" | eval from="search"] | eventstats values(from) as from by DatabaseName | where isnotnull(mvfilter(match(from,"Lookup"))) | foreach CPUUtilization Instance [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=coalesce('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',if(mvcount(from)=1 AND from="Lookup","NULL",null()))] | stats count by DatabaseName CPUUtilization Instance | table DatabaseName CPUUtilization Instance&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 19 Oct 2023 19:19:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665605#M228360</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2023-10-19T19:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Left Outer Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665607#M228361</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;join&lt;/FONT&gt; command is an inefficient way to combine datasets.&amp;nbsp; Alternative commands are described in the Search Reference manual (&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.1/SearchReference/Join#Alternative_commands" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.1/SearchReference/Join#Alternative_commands&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Splunk has a manual for SQL users.&amp;nbsp; See &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 19:24:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665607#M228361</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-10-19T19:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Left Outer Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665627#M228366</link>
      <description>&lt;P&gt;Something like this should work. I called the lookup db_names.csv ... change that to whatever your actual lookup is named. Everything above the comment just emulates the data you gave.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1
| eval _raw="DatabaseName,Instance,CPUUtilization
A,A1,10
A,A2,20
C,C1,40
C,C2,50
D,D,60"
| multikv forceheader=1
| fields - _time, _raw, linecount
```^^^^ This emulates the data you gave ^^^^```
| eval inst_cpu=Instance+"#"+CPUUtilization
| fields - Instance CPUUtilization
| inputlookup db_names.csv append=true ```&amp;lt;-- change the lookup name here```
| stats list(inst_cpu) as inst_cpu by DatabaseName
| mvexpand inst_cpu
| eval Instance=mvindex(split(inst_cpu,"#"), 0)
| eval CPUUtilization=mvindex(split(inst_cpu,"#"), 1)
| fillnull value="NULL" Instance CPUUtilization
| fields - inst_cpu&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 22:33:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665627#M228366</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-10-19T22:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Left Outer Join in Splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665635#M228372</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;one old answer which describe how joins can/should do with splunk&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/What-is-the-relation-between-the-Splunk-inner-left-join-and-the/m-p/391288/thread-id/113948" target="_blank"&gt;https://community.splunk.com/t5/Splunk-Search/What-is-the-relation-between-the-Splunk-inner-left-join-and-the/m-p/391288/thread-id/113948&lt;/A&gt;&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 06:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Left-Outer-Join-in-Splunk/m-p/665635#M228372</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-10-20T06:36:54Z</dc:date>
    </item>
  </channel>
</rss>

