<?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: Union with joins in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617601#M214633</link>
    <description>&lt;P&gt;Also, timechart doesn't work in your example because there is no _time field...&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2022 21:44:42 GMT</pubDate>
    <dc:creator>Racer73b</dc:creator>
    <dc:date>2022-10-18T21:44:42Z</dc:date>
    <item>
      <title>Help with union with joins?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617200#M214484</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I'm trying to optimize the following search because it runs very slow.&amp;nbsp; Looking for some help w/it.&amp;nbsp; I've been exploring the multi-search command also, but cannot figure out how to get it working yet...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| union
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=ShowDeviceProgramOffer AND completion_code=0)
| join type=inner session
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=ShowBackupDeviceProgramOffer AND completed_from_ui=False AND completion_code=0)]
| join type=inner session
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=SetUserOnboardingComplete AND completion_code=0)]
| timechart span=5m dc(session) as total1]

[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=ShowDeviceProgramOffer AND completion_code=0)
| join type=inner session
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=ShowBackupDeviceProgramOffer AND completed_from_ui=False AND completion_code=0)]
| join type=inner session
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=SetUserOnboardingComplete AND completion_code=0)]
| join type=inner session
[search index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" (flow_name=UcdeDeviceOnboarding AND step_name=ShowUcdeActivationStatus AND completion_code=0)]
| timechart span=5m dc(session) as total2]

| timechart span=5m sum(total1) as eval1, sum(total2) as eval2
| eval ActivationFailed=eval1-eval2
| timechart span=5m sum(eval2) as "Accepted &amp;amp; SignedIn", sum(ActivationFailed) as "Activation Failed" partial=f&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617200#M214484</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-17T14:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617228#M214498</link>
      <description>&lt;P&gt;I would &amp;nbsp;start here for reading. Use the guidance to gradually rebuild from scratch. Joins and sub searches introduce all sorts of limits. Even if yours ran faster it will likely miss things.&amp;nbsp;&lt;A href="https://conf.splunk.com/files/2020/slides/TRU1761C.pdf" target="_blank"&gt;https://conf.splunk.com/files/2020/slides/TRU1761C.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 01:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617228#M214498</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2022-10-15T01:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617283#M214521</link>
      <description>&lt;P&gt;To get rid of all those horrible subsearches, try this approach using a single search + stats to do the 'join' and then you can use eval to determine which category of your union it belongs to&lt;/P&gt;&lt;P&gt;Not totally sure what your end goal is, but this should demonstrate how to collapse many subsearches into a single search.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xmo2-aws host=xmo2-prod* sourcetype=oss_app_log "Step completion_code set/reset" 
    ``` Combine all the searcg conditions into a single search command, looking for all permutations required ```
    (flow_name=UcdeDeviceOnboarding AND 
      (step_name=ShowDeviceProgramOffer AND completion_code=0) OR
      (step_name=ShowBackupDeviceProgramOffer AND completed_from_ui=False AND completion_code=0) OR
      (step_name=SetUserOnboardingComplete AND completion_code=0) OR
      (step_name=ShowUcdeActivationStatus AND completion_code=0) 
    )
``` Now aggregate all fields by the session and filter out those with less than 3 step names ``` 
| stats values(*) as * values(step_name) as step_names by session 
| eval step_count=mvcount(step_names) 
| where step_count &amp;lt; 3
``` Now if we have all 4 step names, then we are the total2 type ```
| eval session_type=if(step_count=4, 2, 1) 
``` finally timechart by the session type above ```
| timechart span=5m dc(session) as sessions by session_type
``` rest of your search as needed ```&lt;/LI-CODE&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/67425"&gt;@starcher&lt;/a&gt;&amp;nbsp;indicates, using joins is likely to take you into a world of pain, where you don't realise you are missing data until someone tells you your numbers are wrong&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 22:07:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617283#M214521</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-16T22:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617599#M214631</link>
      <description>&lt;P&gt;this doesn't quite work because the conditions are mutually inclusive.&amp;nbsp; The session has to meet all 3 of the first conditions.&amp;nbsp; Then, if it meets the 4th condition, it is a success.&amp;nbsp; If not, it is a failure.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 21:34:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617599#M214631</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-18T21:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617600#M214632</link>
      <description>&lt;P&gt;I should have said, if it meets the 4th criteria as well as all 3 of the first criteria, then it is a success.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 21:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617600#M214632</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-18T21:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617601#M214633</link>
      <description>&lt;P&gt;Also, timechart doesn't work in your example because there is no _time field...&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 21:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617601#M214633</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-18T21:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617603#M214634</link>
      <description>&lt;P&gt;If I understand correctly, then all sessions containing all 4 steps should be included in the total1 count of sessions with 3 steps, so given the sessions&lt;/P&gt;&lt;P&gt;A=3, B=3, C=4, D=4, E=3&lt;/P&gt;&lt;P&gt;dc(session) for session_type 2 would = 2 (t2) and dc(session) for session_type 1 would be 3 (t1), so the effective dc(session) for any with 3 steps would be&amp;nbsp; &amp;nbsp;t1+t2&lt;/P&gt;&lt;P&gt;so after the timechart, do&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval session_type=if(step_count=4, "t2", "t1") 
| timechart span=5m dc(session) as sessions by session_type
| eval t1=t1+t2&lt;/LI-CODE&gt;&lt;P&gt;does that work?&lt;/P&gt;&lt;P&gt;If not, can you give an example, so I can get my head around it better&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 22:03:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617603#M214634</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-18T22:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617604#M214635</link>
      <description>&lt;P&gt;still, the timechart command doesn't work without _time field, correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 22:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617604#M214635</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-18T22:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617606#M214636</link>
      <description>&lt;P&gt;without knowing your data, it's a little tricky to give an exact solution, but values(*) as * will not include _time, so you can also do values(_time) as _time in the stats to retain _time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 22:25:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617606#M214636</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-18T22:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617615#M214641</link>
      <description>&lt;P&gt;I was able to get that to work.&amp;nbsp; Thanks for the tips!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 00:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617615#M214641</guid>
      <dc:creator>Racer73b</dc:creator>
      <dc:date>2022-10-19T00:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Union with joins</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617625#M214646</link>
      <description>&lt;P&gt;Great! Hope it actually made a performance difference&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 01:51:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-union-with-joins/m-p/617625#M214646</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-19T01:51:44Z</dc:date>
    </item>
  </channel>
</rss>

