<?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 newbie : how to compare two events from different source in one index by data in event and subtract time diff in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541282#M153246</link>
    <description>&lt;P&gt;Please help. I just completed self learning fundamentals and already have a task I want to try, first post here so please be gentle :-).&lt;/P&gt;&lt;P&gt;I have two files containing job run details for two different jobs over 3 months. it also contains a julian date format from the mainframe but the event data is very similar.&lt;/P&gt;&lt;P&gt;The jobs have a relationship in that on a particular day job_a(file1) is a prerequisite to job_b(file 2).&lt;/P&gt;&lt;P&gt;in pseudo : I&amp;nbsp; want to calculate the difference between the time job_a started and the time job_b started for each day. Assumptions confirmed&amp;nbsp; : job_a is always earlier then job_b difference in hh:mm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is the regex I used to convert the julian to gregorian while importing each of the files so I could use the event data as my _time and date in the index :&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;timestamp format regex = %y%j%H.%M.%S.%N&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;timestamp prefix regex = [A-Z][A-Z]\d\d\s\d\d&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Here is the sample records in each file : Delimited by space : fileds = Julian_date time jobname jobnr&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;FILE1 : 2 sample records :&lt;/U&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;EM&gt;2021056 00.30.06.05 JOB_A &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2021055 01.30.10.43 JOB_A&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;FILE2 : 2 sample records :&lt;/U&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;EM&gt;2021056 03.30.23.50 JOB_B &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2021055 02.00.10.43 JOB_B&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;the output I would like to achieve is&amp;nbsp; :&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&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; DATE&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOB_A_START&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOB_B_START&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; START_TIME_DIFF&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;SPAN class="output-date"&gt;2021-02-24&lt;/SPAN&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;EM&gt;00H30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03H30 &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; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03H00&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;SPAN class="output-date"&gt;2021-02-23&lt;/SPAN&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;EM&gt;01H30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02H00&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; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00H30&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate the approach thinking as well (i.e. why steps are done) because I found myself questioning even how I would approach the index and source and source-types because I ended up just coding a lot of SPL trying to get to something that looks like it will work(Eventually ended up deleting the index). I was very comfortable dealing each file individually creating graphs etc... but the minute the second one came in and I needed it as a "joint" output plus comparing the date fields and subtracting it in the event data etc..etc.. I realized I was now more confused than with a single file... I think if I can get the thought process of an experienced person it will really help(this is something I miss due to trying self learning &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope the above is clearly articulated.&lt;/P&gt;&lt;P&gt;Again, thanks in advance.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2021 22:41:27 GMT</pubDate>
    <dc:creator>KING_JULIAN</dc:creator>
    <dc:date>2021-02-24T22:41:27Z</dc:date>
    <item>
      <title>newbie : how to compare two events from different source in one index by data in event and subtract time diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541282#M153246</link>
      <description>&lt;P&gt;Please help. I just completed self learning fundamentals and already have a task I want to try, first post here so please be gentle :-).&lt;/P&gt;&lt;P&gt;I have two files containing job run details for two different jobs over 3 months. it also contains a julian date format from the mainframe but the event data is very similar.&lt;/P&gt;&lt;P&gt;The jobs have a relationship in that on a particular day job_a(file1) is a prerequisite to job_b(file 2).&lt;/P&gt;&lt;P&gt;in pseudo : I&amp;nbsp; want to calculate the difference between the time job_a started and the time job_b started for each day. Assumptions confirmed&amp;nbsp; : job_a is always earlier then job_b difference in hh:mm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is the regex I used to convert the julian to gregorian while importing each of the files so I could use the event data as my _time and date in the index :&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;timestamp format regex = %y%j%H.%M.%S.%N&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;timestamp prefix regex = [A-Z][A-Z]\d\d\s\d\d&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Here is the sample records in each file : Delimited by space : fileds = Julian_date time jobname jobnr&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;FILE1 : 2 sample records :&lt;/U&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;EM&gt;2021056 00.30.06.05 JOB_A &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2021055 01.30.10.43 JOB_A&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;U&gt;FILE2 : 2 sample records :&lt;/U&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;EM&gt;2021056 03.30.23.50 JOB_B &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2021055 02.00.10.43 JOB_B&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;the output I would like to achieve is&amp;nbsp; :&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&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; DATE&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOB_A_START&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOB_B_START&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; START_TIME_DIFF&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;SPAN class="output-date"&gt;2021-02-24&lt;/SPAN&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;EM&gt;00H30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03H30 &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; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03H00&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;SPAN class="output-date"&gt;2021-02-23&lt;/SPAN&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;EM&gt;01H30 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02H00&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; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00H30&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate the approach thinking as well (i.e. why steps are done) because I found myself questioning even how I would approach the index and source and source-types because I ended up just coding a lot of SPL trying to get to something that looks like it will work(Eventually ended up deleting the index). I was very comfortable dealing each file individually creating graphs etc... but the minute the second one came in and I needed it as a "joint" output plus comparing the date fields and subtracting it in the event data etc..etc.. I realized I was now more confused than with a single file... I think if I can get the thought process of an experienced person it will really help(this is something I miss due to trying self learning &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope the above is clearly articulated.&lt;/P&gt;&lt;P&gt;Again, thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 22:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541282#M153246</guid>
      <dc:creator>KING_JULIAN</dc:creator>
      <dc:date>2021-02-24T22:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: newbie : how to compare two events from different source in one index by data in event and subtract time diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541509#M153319</link>
      <description>&lt;P&gt;If I understand correctly, then the process might look like this (although I'm sure there are many ways to get this done)&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&amp;nbsp;Get all events from both files&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;Create a date field for every event based on timestamp&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;Get the earliest &amp;amp; latest events for each date&lt;/LI&gt;&lt;LI&gt;Calculate the elapsed time between those&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;Format / Table / Sort fields&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This assumes one event per day for each file and as you said job_b is always the later event.&amp;nbsp; If it is more complex than that, then the search would get a bit more complex too.&lt;/P&gt;&lt;P&gt;But something like this I think:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search both files&amp;gt;
| eval date = strftime(_time,"%Y-%m-%d")
| stats earliest(_time) as job_a, latest(_time) as job_b by date
| eval elapsed = tostring(job_b - job_a,"duration")
| eval job_a = strftime(job_a,"%H:%M"), job_b = strftime(job_b,"%H:%M")
| table date, job_a, job_b, elapsed
| sort date&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 13:32:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541509#M153319</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2021-02-26T13:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: newbie : how to compare two events from different source in one index by data in event and subtract time diff</title>
      <link>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541679#M153371</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190949"&gt;@maciep&lt;/a&gt;thank you , thank you.... This worked even straight as a copy and paste :-). However, and more important, is that I started from scratch importing the files and building the INDEX and realized why I confused myself so much. My problem was that I was creating different source-types when trying the field extractions and trying to call it differently(i.e. joba_jdate &amp;amp; jobb_jdate...), this made me realize that I was trying to follow structured programming constructs, which meant at some point I was thinking along the lines of i.e.&amp;nbsp; "if joba_jdate &amp;lt; jobb_jdate ...do xyz , etc...) which is what confused me even more.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok so it was nice trying to tackle this with my own data and problem cause it makes so much more sense then learning tutorial exercises etc ...&lt;/P&gt;&lt;P&gt;Thanks again and much appreciated. "ps! I'LL BE BACK &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; " ...&lt;/P&gt;&lt;P&gt;Stay safe.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 18:54:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/newbie-how-to-compare-two-events-from-different-source-in-one/m-p/541679#M153371</guid>
      <dc:creator>KING_JULIAN</dc:creator>
      <dc:date>2021-02-28T18:54:33Z</dc:date>
    </item>
  </channel>
</rss>

