<?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 Combine two searches left outer style in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289608#M87610</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I have an index which gets data of manual IT system scans with the following structure (simplified for example):&lt;BR /&gt;
SCAN_ID - this is an unique name of the scan performed&lt;BR /&gt;
VLN_ID - item of the scan performed - there are 254 such. Unique (within every Scan_Id)&lt;BR /&gt;
VLN_CTRL_FIND - result of the scanned item, 0-correct/1-finding&lt;BR /&gt;
 - will be mentioned later!&lt;/P&gt;

&lt;P&gt;Not all items are scanned, some may be disabled, so not all scans have 254 events!&lt;/P&gt;

&lt;P&gt;I have loaded three scans, with the number of rows as below:&lt;/P&gt;

&lt;P&gt;20170705_131430_OraScan     252     &lt;/P&gt;

&lt;H2&gt;20170705_135210_OraScan     252&lt;/H2&gt;

&lt;P&gt;20170703_233304_OraScan     254 &lt;/P&gt;

&lt;P&gt;The first two scans are missing VLN_IDs 7 and 251 - thus the total is -2 from the last one which was a "full" scan&lt;/P&gt;

&lt;P&gt;What I need to achieve is a search that combines two scans - Scan Run vs Scan Baseline.&lt;BR /&gt;
All rows of Scan Run must be displayed, even when Baseline has less.&lt;/P&gt;

&lt;P&gt;So I tried the following command to compare: &lt;BR /&gt;
Scan Run - 20170703_233304_OraScan&lt;BR /&gt;
with&lt;BR /&gt;
Scan Baseline - 20170705_135210_OraScan&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=omega_ds_idx_01 SCAN_ID="20170703_233304_OraScan"
| join type=outer
[ SEARCH 
index=omega_ds_idx_01 SCAN_ID="20170705_135210_OraScan"
| rename VLN_ID as VLN_ID2, SCAN_ID as SCAN_ID2, VLN_CTRL_FIND as VLN_CTRL_FIND2 
]
| where VLN_ID=VLN_ID2
| table _time, VLN_ID, VLN_ID2, SCAN_ID, SCAN_ID2, VLN_CTRL_FIND, VLN_CTRL_FIND2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Problem 1:&lt;BR /&gt;
the command outputted 121 rows! I was expecting 254 (or least 252) !&lt;/P&gt;

&lt;P&gt;Problem 2:&lt;BR /&gt;
I switched in search the Baseline 20170705_135210_OraScan to 20170705_131430_OraScan - a previous scan.&lt;BR /&gt;
This time the result was 252 rows! &lt;BR /&gt;
Both Baseline Scans 20170705_135210_OraScan and 20170705_131430_OraScan have the same number of rows - 252! &lt;BR /&gt;
And their VLN_IDs are identically the same within them and also with those of the unchanged Scan Run 20170703_233304_OraScan&lt;BR /&gt;
So why this inconsistency on the results ?&lt;/P&gt;

&lt;P&gt;In general, what I am trying to achieve is something simple like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select a.Vln_id, a.Vln_Name, ...,  
a.Vln_Ctrl_Find_Run, b.Vln_Ctrl_Find_Run

from &amp;lt;search_run&amp;gt; a, &amp;lt;search_baseline&amp;gt; b

where a.Vln_Id = b.Vln_Id(+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have not found a way so far to achieve the above,&lt;BR /&gt;
please advise&lt;/P&gt;

&lt;P&gt;at your disposal for further info&lt;BR /&gt;
best regards&lt;BR /&gt;
Altin&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:42:56 GMT</pubDate>
    <dc:creator>altink</dc:creator>
    <dc:date>2020-09-29T14:42:56Z</dc:date>
    <item>
      <title>Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289608#M87610</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I have an index which gets data of manual IT system scans with the following structure (simplified for example):&lt;BR /&gt;
SCAN_ID - this is an unique name of the scan performed&lt;BR /&gt;
VLN_ID - item of the scan performed - there are 254 such. Unique (within every Scan_Id)&lt;BR /&gt;
VLN_CTRL_FIND - result of the scanned item, 0-correct/1-finding&lt;BR /&gt;
 - will be mentioned later!&lt;/P&gt;

&lt;P&gt;Not all items are scanned, some may be disabled, so not all scans have 254 events!&lt;/P&gt;

&lt;P&gt;I have loaded three scans, with the number of rows as below:&lt;/P&gt;

&lt;P&gt;20170705_131430_OraScan     252     &lt;/P&gt;

&lt;H2&gt;20170705_135210_OraScan     252&lt;/H2&gt;

&lt;P&gt;20170703_233304_OraScan     254 &lt;/P&gt;

&lt;P&gt;The first two scans are missing VLN_IDs 7 and 251 - thus the total is -2 from the last one which was a "full" scan&lt;/P&gt;

&lt;P&gt;What I need to achieve is a search that combines two scans - Scan Run vs Scan Baseline.&lt;BR /&gt;
All rows of Scan Run must be displayed, even when Baseline has less.&lt;/P&gt;

&lt;P&gt;So I tried the following command to compare: &lt;BR /&gt;
Scan Run - 20170703_233304_OraScan&lt;BR /&gt;
with&lt;BR /&gt;
Scan Baseline - 20170705_135210_OraScan&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=omega_ds_idx_01 SCAN_ID="20170703_233304_OraScan"
| join type=outer
[ SEARCH 
index=omega_ds_idx_01 SCAN_ID="20170705_135210_OraScan"
| rename VLN_ID as VLN_ID2, SCAN_ID as SCAN_ID2, VLN_CTRL_FIND as VLN_CTRL_FIND2 
]
| where VLN_ID=VLN_ID2
| table _time, VLN_ID, VLN_ID2, SCAN_ID, SCAN_ID2, VLN_CTRL_FIND, VLN_CTRL_FIND2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Problem 1:&lt;BR /&gt;
the command outputted 121 rows! I was expecting 254 (or least 252) !&lt;/P&gt;

&lt;P&gt;Problem 2:&lt;BR /&gt;
I switched in search the Baseline 20170705_135210_OraScan to 20170705_131430_OraScan - a previous scan.&lt;BR /&gt;
This time the result was 252 rows! &lt;BR /&gt;
Both Baseline Scans 20170705_135210_OraScan and 20170705_131430_OraScan have the same number of rows - 252! &lt;BR /&gt;
And their VLN_IDs are identically the same within them and also with those of the unchanged Scan Run 20170703_233304_OraScan&lt;BR /&gt;
So why this inconsistency on the results ?&lt;/P&gt;

&lt;P&gt;In general, what I am trying to achieve is something simple like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select a.Vln_id, a.Vln_Name, ...,  
a.Vln_Ctrl_Find_Run, b.Vln_Ctrl_Find_Run

from &amp;lt;search_run&amp;gt; a, &amp;lt;search_baseline&amp;gt; b

where a.Vln_Id = b.Vln_Id(+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have not found a way so far to achieve the above,&lt;BR /&gt;
please advise&lt;/P&gt;

&lt;P&gt;at your disposal for further info&lt;BR /&gt;
best regards&lt;BR /&gt;
Altin&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:42:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289608#M87610</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2020-09-29T14:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289609#M87611</link>
      <description>&lt;P&gt;This is one of the many cases in splunk when a &lt;CODE&gt;join&lt;/CODE&gt; can (and should) be avoided altogether.&lt;/P&gt;

&lt;P&gt;Try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=omega_ds_idx_01 (SCAN_ID="20170703_233304_OraScan" OR SCAN_ID="20170705_135210_OraScan")
| table SCAN_ID VLN_ID VLN_CTRL_FIND 
| eventstats min(SCAN_ID) as SCAN1, max(SCAN_ID) as SCAN2 
| eval VLN_CTRL_FIND1=if(SCAN_ID=SCAN1,VLN_CTRL_FIND,null())
| eval VLN_CTRL_FIND2=if(SCAN_ID=SCAN2,VLN_CTRL_FIND,null())
| fields - VLN_CTRL_FIND SCAN_ID
| stats values(*) as * by VLN_ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 18:45:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289609#M87611</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-07-05T18:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289610#M87612</link>
      <description>&lt;P&gt;Tried again with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=omega_ds_idx_01 SCAN_ID="20170703_233304_OraScan" 
| join VLN_ID 
[ SEARCH 
index=omega_ds_idx_01 SCAN_ID="20170705_135210_OraScan"
| rename SCAN_ID as SCAN_ID2, VLN_CTRL_FIND as VLN_CTRL_FIND2 
]
| table _time, VLN_ID, VLN_ID2, SCAN_ID, SCAN_ID2, VLN_CTRL_FIND, VLN_CTRL_FIND2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This time I got 252 rows instead of the previous 121.&lt;/P&gt;

&lt;P&gt;However I need to have the full 254 from the 20170703_233304_OraScan and not only what matches (VLN_ID)&lt;BR /&gt;
to the other.&lt;/P&gt;

&lt;P&gt;please advise&lt;BR /&gt;
Altin&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289610#M87612</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2020-09-29T14:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289611#M87613</link>
      <description>&lt;P&gt;Thank you very much Mr. DalJeanis&lt;/P&gt;

&lt;P&gt;I tried your command, but it returned 506 events (double of 254).&lt;BR /&gt;
Something must be not right.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 19:51:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289611#M87613</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2017-07-05T19:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289612#M87614</link>
      <description>&lt;P&gt;sorry I missed the 506 for row number.&lt;BR /&gt;
the command is OK.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 19:56:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289612#M87614</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2017-07-05T19:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Combine two searches left outer style</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289613#M87615</link>
      <description>&lt;P&gt;thank you very much&lt;/P&gt;

&lt;P&gt;the command you gave me works and I have the expected results.&lt;/P&gt;

&lt;P&gt;However (to my knowledge) it is a bit complicated.&lt;/P&gt;

&lt;P&gt;I can have the same result with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=omega_ds_idx_01 SCAN_ID="20170703_233304_OraScan" 
| join VLN_ID type=outer 
[ SEARCH 
index=omega_ds_idx_01 SCAN_ID="20170705_135210_OraScan"
| rename SCAN_ID as SCAN_ID2, VLN_CTRL_FIND as VLN_CTRL_FIND2
]
| table _time, VLN_ID, SCAN_ID, SCAN_ID2, VLN_CTRL_FIND, VLN_CTRL_FIND2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is the above approach OK ? I have read the Join syntax, but other than limitations on [SEARCH], found no reason not to use it.&lt;BR /&gt;
I would like to continue with the approach above - if it it technically correct&lt;/P&gt;

&lt;P&gt;please advise&lt;/P&gt;

&lt;P&gt;thanks and regards&lt;BR /&gt;
Altin&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 20:03:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combine-two-searches-left-outer-style/m-p/289613#M87615</guid>
      <dc:creator>altink</dc:creator>
      <dc:date>2017-07-05T20:03:49Z</dc:date>
    </item>
  </channel>
</rss>

