<?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 join distinct data sources and grouping logically? in Other Usage</title>
    <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657426#M761</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; thanks for your inputs.&lt;/P&gt;&lt;P&gt;source 2 events are not tied to the physical clock and a single day in application could span multiple days in calendar or multiple days in application can fit in a single calendar day time frame.&lt;/P&gt;&lt;P&gt;i'm exploring the option of populating these two sources separately in dashboard and try to pass the source 1 date/time as inputs to source 2 and get the events by each logical date.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 13:02:34 GMT</pubDate>
    <dc:creator>Paluri</dc:creator>
    <dc:date>2023-09-13T13:02:34Z</dc:date>
    <item>
      <title>How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657336#M758</link>
      <description>&lt;P&gt;Two different sources returning data in the below format.&lt;/P&gt;
&lt;P&gt;Source 1 - Determines the time range for a given date based on the execution of a Job, which logically concludes the End of Day in Application.&lt;/P&gt;
&lt;P&gt;Source 2 – Events generated in real time for various use cases in the application. EventID1 is generated as part of the Job in Source1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source 1&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="84"&gt;
&lt;P&gt;DATE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="186"&gt;
&lt;P&gt;Start Time&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="192"&gt;
&lt;P&gt;End Time&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84"&gt;
&lt;P&gt;Day 3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="186"&gt;
&lt;P&gt;2023-09-12 01:12:12.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="192"&gt;
&lt;P&gt;2023-09-13 01:13:13.123&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84"&gt;
&lt;P&gt;Day 2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="186"&gt;
&lt;P&gt;2023-09-11 01:11:11.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="192"&gt;
&lt;P&gt;2023-09-12 01:12:12.123&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84"&gt;
&lt;P&gt;Day 1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="186"&gt;
&lt;P&gt;2023-09-10 01:10:10.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="192"&gt;
&lt;P&gt;2023-09-11 01:11:11.123&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source 2&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;Event type&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;Time&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;Others&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-11 01:20:20.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-11 01:11:11.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID9&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-10 01:20:30.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID3&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-10 01:20:10.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID5&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-10 01:10:20.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="156"&gt;
&lt;P&gt;EventID1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="168"&gt;
&lt;P&gt;2023-09-10 01:10:10.123&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="144"&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are no common fields available to join the two sources other than the time at which the job is executed and at which the EventID1 is generated.&lt;/P&gt;
&lt;P&gt;Expectation is to logically group the events based on Date and derive the stats for each day.&lt;/P&gt;
&lt;P&gt;I'm new to Splunk and i would really appreciate if you guys can provide suggestions on how to handle this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected Result&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="120"&gt;
&lt;P&gt;Date&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="108"&gt;
&lt;P&gt;Events&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="102"&gt;
&lt;P&gt;Count&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120"&gt;
&lt;P&gt;Day 1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="108"&gt;
&lt;P&gt;EventID1&lt;BR /&gt;EventID2&lt;BR /&gt;EventID3&lt;BR /&gt;- - -&lt;BR /&gt;EventID9&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="102"&gt;
&lt;P&gt;1&lt;BR /&gt;15&lt;BR /&gt;10&lt;BR /&gt;- -&lt;BR /&gt;8&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="120"&gt;
&lt;P&gt;Day 2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="108"&gt;
&lt;P&gt;EventID1&lt;BR /&gt;EventID2&lt;BR /&gt;- - -&lt;BR /&gt;EventID9&lt;BR /&gt;EventID11&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="102"&gt;
&lt;P&gt;1&lt;BR /&gt;2&lt;BR /&gt;- -&lt;BR /&gt;18&lt;BR /&gt;6&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:25:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657336#M758</guid>
      <dc:creator>Paluri</dc:creator>
      <dc:date>2023-09-12T21:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657379#M759</link>
      <description>&lt;P&gt;If you paste this into your search window, you can see it being done with your example dataset&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="DATE,Start_Time,End_Time
Day_3,2023-09-12 01:12:12.123,2023-09-13 01:13:13.123
Day_2,2023-09-11 01:11:11.123,2023-09-12 01:12:12.123
Day_1,2023-09-10 01:10:10.123,2023-09-11 01:11:11.123"
| multikv forceheader=1
| table DATE Start_Time End_Time
| eval _time = relative_time(strptime(Start_Time, "%F %T.%Q"), "@d")
| append [ 
  | makeresults
  | eval _raw="Event type,Time,Others
EventID2,2023-09-11 01:20:20.123,
EventID1,2023-09-11 01:11:11.123,
EventID9,2023-09-10 01:20:30.123,
EventID3,2023-09-10 01:20:10.123,
EventID5,2023-09-10 01:10:20.123,
EventID1,2023-09-10 01:10:10.123,"
  | multikv forceheader=1
  | table Event_type Time
  | eval _time = strptime(Time, "%F %T.%Q")
  | fields - Time
]
| bin _time span=1d
| stats list(*) as * count by _time&lt;/LI-CODE&gt;&lt;P&gt;but the way you should do this is to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;search source1 OR search source2
| eval _time = if(event=from_source_1, 
     relative_time(strptime(Start_Time, "%F %T.%Q"), "@d"), 
     strptime(Time, "%F %T.%Q"))
| bin _time span=1d
| stats list(*) as * count by _time&lt;/LI-CODE&gt;&lt;P&gt;so this will create a _time field for the source 1 events that is the start of the day, it creates a _time field based on source 2 event times and then uses BIN to create a 1 day grouping and then stats list to collect them together. Count will always be one more than the source 2 events.&lt;/P&gt;&lt;P&gt;Note that this&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;assumes each source 1 event only occurs once on a day&lt;/LI&gt;&lt;LI&gt;assumes that source 2 events will not occur outside the time range of source 1 range&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 03:10:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657379#M759</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-13T03:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657380#M760</link>
      <description>&lt;P&gt;the if (event=from_source1... is a test you will have to make using whatever fields you have to indicate the data is a souce1 event (source/sourcetype/index?)&lt;/P&gt;&lt;P&gt;If you need to only take source 2 events that are inside the source1 window or it can span more than one day, you'll have to do it a bit differently&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 03:12:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657380#M760</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-13T03:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657426#M761</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; thanks for your inputs.&lt;/P&gt;&lt;P&gt;source 2 events are not tied to the physical clock and a single day in application could span multiple days in calendar or multiple days in application can fit in a single calendar day time frame.&lt;/P&gt;&lt;P&gt;i'm exploring the option of populating these two sources separately in dashboard and try to pass the source 1 date/time as inputs to source 2 and get the events by each logical date.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 13:02:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657426#M761</guid>
      <dc:creator>Paluri</dc:creator>
      <dc:date>2023-09-13T13:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657503#M762</link>
      <description>&lt;P&gt;Actually it's not so hard to achieve.&lt;/P&gt;&lt;P&gt;Here is another example, where I have added another Day 0 and some event dates inside and outside any day.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="DATE,Start_Time,End_Time
Day_3,2023-09-12 01:12:12.003,2023-09-13 01:13:13.993
Day_2,2023-09-11 01:11:11.002,2023-09-12 01:12:12.992
Day_1,2023-09-10 01:10:10.001,2023-09-11 01:11:11.991
Day_0,2023-09-04 01:12:12.000,2023-09-06 17:22:13.990"
| multikv forceheader=1
| table DATE Start_Time End_Time
| eval _time = strptime(Start_Time, "%F %T.%Q")
| eval end = strptime(End_Time, "%F %T.%Q"), start=_time
| append [ 
  | makeresults
  | eval _raw="Event type,Time,Others
EventID2,2023-09-11 01:20:20.133,  ``` INSIDE DAY 2 ```
EventID1,2023-09-11 01:11:11.132,  ``` INSIDE DAY 2 ```
EventID9,2023-09-10 01:20:30.131,  ``` INSIDE DAY 1 ```
EventID3,2023-09-10 01:20:10.130,  ``` INSIDE DAY 1 ```
EventID5,2023-09-10 01:10:20.129,  ``` INSIDE DAY 1 ```
EventID1,2023-09-10 01:10:10.128,  ``` INSIDE DAY 1 ```
EventID4,2023-09-07 01:10:10.127,  ``` OUTSIDE ANY ```
EventID3,2023-09-06 06:10:10.126,  ``` INSIDE DAY 0 ```
EventID2,2023-09-05 19:10:10.125,  ``` INSIDE DAY 0 ```
EventID1,2023-09-04 04:10:10.124,  ``` INSIDE DAY 0 ```
EventID0,2023-09-04 01:10:10.123," ``` OUTSIDE ANY ```
  | multikv forceheader=1
  | table Event_type Time
  | eval _time = strptime(Time, "%F %T.%Q")
  | eval eventTime=_time
  | fields - Time
]
| sort _time

| filldown DATE start end
| eval eventIsInside=case(isnull(Event_type), "YES", isnotnull(Event_type) AND _time&amp;gt;=start AND _time&amp;lt;=end, "YES", 1==1, "NO")
| where eventIsInside="YES"
| stats values(*_Time) as *_Time list(Event_type) as eventIDs list(eventTime) as eventTimes by DATE
| eval eventTimes=strftime(eventTimes, "%F %T.%Q")
| table DATE Start_Time End_Time eventIDs eventTimes&lt;/LI-CODE&gt;&lt;P&gt;You can see that this works by making a common time, which is based on either start time or event time and then sorting by time.&lt;/P&gt;&lt;P&gt;Setting start and end epoch times for the source 1 data means you can then 'filldown' those fields to subsequent event (source 2) rows until the next source 1 Day.&lt;/P&gt;&lt;P&gt;Then as each event source 2 now has the preceeding day's start/end time, it can make the comparison for it's own time.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 23:12:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657503#M762</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-13T23:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to join distinct data sources and grouping logically?</title>
      <link>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657514#M763</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; this is closer to what i'm trying to achieve and has given me some idea on how to work on splunk searches of this complexity.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 01:23:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/How-to-join-distinct-data-sources-and-grouping-logically/m-p/657514#M763</guid>
      <dc:creator>Paluri</dc:creator>
      <dc:date>2023-09-14T01:23:18Z</dc:date>
    </item>
  </channel>
</rss>

