<?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 do you Join tables using a common field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388841#M113379</link>
    <description>&lt;P&gt;Also, regarding the join, the failure table has only failures hence everthing is a bad ExitCode and i cannot filter it based on that. &lt;/P&gt;

&lt;P&gt;Re Index, i was told by one of admins that they have only one index for some reason( i might be wrong)  hence they dont specify the index at all. I will reconfirm them. &lt;/P&gt;</description>
    <pubDate>Wed, 09 Jan 2019 03:46:47 GMT</pubDate>
    <dc:creator>umakanth_k</dc:creator>
    <dc:date>2019-01-09T03:46:47Z</dc:date>
    <item>
      <title>How do you Join tables using a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388838#M113376</link>
      <description>&lt;P&gt;Hi all &lt;/P&gt;

&lt;P&gt;I am very new to Splunk, hoping someone can help me. &lt;/P&gt;

&lt;P&gt;I am working on creating a dashboard that gives us a summary of our Windows 10 upgrades.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;&amp;lt;i&amp;gt;source="dbc:sccm:inv"&amp;lt;/i&amp;gt; (run every day)&lt;/CODE&gt; =  has the device name, Operating System version and other details&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;&amp;lt;i&amp;gt;sourcetype=sccm:task_sequence_summary&amp;lt;/i&amp;gt;&lt;/CODE&gt; (configured as rising column) = has the Windows 10 deployment summary&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;&amp;lt;i&amp;gt;sourcetype=sccm:task_sequence_failures&amp;lt;/i&amp;gt;&lt;/CODE&gt;  (configured as rising column) = this has the failure information which includes why it failed, which step and the exit codes. &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;In &lt;CODE&gt;source="dbc:sccm:inv&lt;/CODE&gt;", there would be Windows 10 and other Operating system devices as well. &lt;/P&gt;

&lt;P&gt;I am trying to combine the fields from all the above sources/sourcetypes so that if it is a Windows 10 device, other fields are populated if not empty. &lt;/P&gt;

&lt;P&gt;e.g &lt;BR /&gt;
&lt;B&gt;Hostname, OS&lt;/B&gt; (source="dbc:sccm:inv")&lt;BR /&gt;
Device 1, Windows 7&lt;BR /&gt;
Device 2, Windows 10&lt;BR /&gt;
Device 3, Windows 10&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Hostname, LastSateName&lt;/B&gt; (sourcetype=sccm:task_sequence_summary)&lt;BR /&gt;
Device 2, Failed&lt;BR /&gt;
Device 3, Successful &lt;/P&gt;

&lt;P&gt;&lt;B&gt;Hostname, ExitCode&lt;/B&gt; (sourcetype=sccm:task_sequence_failures)&lt;BR /&gt;
Device 2, 10001&lt;/P&gt;

&lt;P&gt;I want the below :&lt;/P&gt;

&lt;P&gt;Hostname, OS, LastStateName, ExitCode&lt;BR /&gt;
Device 1, Windows 7&lt;BR /&gt;
Device 2, Windows 10, Failed, 10001&lt;BR /&gt;
Device 3, Windows 10, Successful &lt;/P&gt;

&lt;P&gt;I want to join the 3rd table (i.e sourcetype=sccm:task_sequence_failures) only if device failed to upgrade. &lt;/P&gt;

&lt;P&gt;I am doing something like below. It works but is very slow because of the left join (the nested left join reduced the exectution a bit)&lt;/P&gt;

&lt;P&gt;I was adviced not to use joins as they are slow and "stats" would be a better option. &lt;/P&gt;

&lt;P&gt;I tried using a bit of "stats" but couldnt achieve much. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="dbc:sccm:inv"
| dedup Hostname sortby -_time 
| join type=left Hostname 
    [| search sourcetype=sccm:task_sequence_summary earliest=1 
    | dedup Hostname sortby -LastStatusTime 
    | join type=left Hostname 
        [| search sourcetype=sccm:task_sequence_failures earliest=1 
        | dedup Hostname sortby -ExecutionTime 
        | eval FailureCause=
            case(
            ExitCode = "10001", "Failed due to reason 1",
            ExitCode = "10002", "Failed due to reason 2",
            1=1,"Unknown"
            ) 
            ] 
    | eval FailureCause=
        case (
        LastStateName = "Failed", FailureCause,
        1=1, ""
        ) 
    | eval ExitCode=
        case (
        LastStateName = "Failed", ExitCode,
        1=1, ""
        )] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:36:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388838#M113376</guid>
      <dc:creator>umakanth_k</dc:creator>
      <dc:date>2020-09-29T22:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Join tables using a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388839#M113377</link>
      <description>&lt;P&gt;Can you elaborate on your mileage with stats? If you could share a sanitized copy of your output and why it's not working that would be helpful.&lt;/P&gt;

&lt;P&gt;The goal with stats is to get all the data for your common field (Hostname) up front and then process it from there. I would try something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(source="dbc:sccm:inv" Hostname="*") OR (sourcetype=sccm:task_sequence_summary Hostname="*") OR (sourcetype=sccm:task_sequence_failures Hostname="*" ExitCode="*")
| dedup sourcetype,Hostname sortby -_indextime
| eval FailureCause=case(ExitCode=="10001","Failed due to reason 1",ExitCode=="10002","Failed due to reason 2",True(),"No failure code found")
| eval FailureCause=case(LastStateName=="Failed",FailureCause,True(),NULL())
| eval ExitCode=case(LastStateName=="Failed",ExitCode,True(),NULL())
| stats first(*) AS * by Hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you must use join, you can speed up the subsearch a bit by including only results containing a bad ExitCode.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(sourcetype=sccm:task_sequence_failures Hostname="*" ExitCode="10001" OR ExitCode="10002")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also consider specifying index=YourIndex in your searches to save Splunk from looking through all indexes for those sourcetypes. If it had a hit in a non-internal index for that source or sourcetype key/value pair it might include it, which is undesirable.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 17:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388839#M113377</guid>
      <dc:creator>afurrowgtri</dc:creator>
      <dc:date>2019-01-08T17:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Join tables using a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388840#M113378</link>
      <description>&lt;P&gt;To be honest i am not good with stats and i use it only for the basic functions and not for joining tables. &lt;BR /&gt;
I tried the below, it joins but for some reason it does not provide the right info.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(source="dbc:sccm:inv" Hostname="*") OR (sourcetype=sccm:task_sequence_summary Hostname="*") OR (sourcetype=sccm:task_sequence_failures Hostname="*" ExitCode="*")
 | stats first(*) AS * by Hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It could be that the way we are pulling data is wrong hence adds to the complexity.&lt;/P&gt;

&lt;P&gt;Like i mentioned :&lt;BR /&gt;
source="dbc:sccm:inv" = runs every 12 hours and has all devices info&lt;BR /&gt;
sourcetype=sccm:task_sequence_summary (configured as rising column) = this has only delta&lt;BR /&gt;
sourcetype=sccm:task_sequence_failures (configured as rising column) = this has only delta&lt;/P&gt;

&lt;P&gt;Because of which i want "dbc:sccm:inv" to have 12 hours and the other 2 tables to be searched with "all time"&lt;BR /&gt;
 Would adding earliest=1 in the 2 other searches and pick 12 hours in the time picker for the main search work?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (source="dbc:sccm:inv" Hostname="*") OR (sourcetype=sccm:task_sequence_summary Hostname="*" earliest=1) OR (sourcetype=sccm:task_sequence_failures Hostname="*" ExitCode="*" earliest=1)
     | stats first(*) AS * by Hostname --- 12 hours in the time picker
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the below scenario "Device 2" will go through multiple states (waiting, failed, successful etc) and i need only the latest one based on the ExecutionTime.&lt;BR /&gt;
How will "stats" work in this scenario. Which state does Device 2 get?&lt;/P&gt;

&lt;P&gt;Also though Device 2 has a failure info in the 3rd table it was successful in the 2nd table hence it should not failure info. I can use this but just asking.&lt;BR /&gt;
| eval FailureCause=case(LastStateName=="Failed",FailureCause,True(),NULL())&lt;BR /&gt;
 | eval ExitCode=case(LastStateName=="Failed",ExitCode,True(),NULL())&lt;/P&gt;

&lt;P&gt;In summary a device needs to have a state based on the execution time (2nd table) and only if it is failed is when it should have the failure details (3rd table) .&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Hostname, OS&lt;/B&gt; (source="dbc:sccm:inv")&lt;BR /&gt;
Device 1, Windows 7&lt;BR /&gt;
Device 2, Windows 10&lt;BR /&gt;
Device 3, Windows 10&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Hostname, LastSateName, ExecutionTime&lt;/B&gt; (sourcetype=sccm:task_sequence_summary)&lt;BR /&gt;
Device 2, Successful, 1 Jan&lt;BR /&gt;
Device 2, Failed, 20 Dec&lt;BR /&gt;
Device 2, Running, 13 Dec &lt;BR /&gt;
Device 2, Waiting, 12 Dec&lt;BR /&gt;
Device 3, Successful, 12 Dec&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Hostname, ExitCode&lt;/B&gt; (sourcetype=sccm:task_sequence_failures)&lt;BR /&gt;
Device 2, 10001&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388840#M113378</guid>
      <dc:creator>umakanth_k</dc:creator>
      <dc:date>2020-09-29T22:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you Join tables using a common field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388841#M113379</link>
      <description>&lt;P&gt;Also, regarding the join, the failure table has only failures hence everthing is a bad ExitCode and i cannot filter it based on that. &lt;/P&gt;

&lt;P&gt;Re Index, i was told by one of admins that they have only one index for some reason( i might be wrong)  hence they dont specify the index at all. I will reconfirm them. &lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 03:46:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-Join-tables-using-a-common-field/m-p/388841#M113379</guid>
      <dc:creator>umakanth_k</dc:creator>
      <dc:date>2019-01-09T03:46:47Z</dc:date>
    </item>
  </channel>
</rss>

