<?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: Capturing &amp;amp; Comparing _time from two searches using append ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614309#M213462</link>
    <description>&lt;P&gt;You could try the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;index=anIndex sourcetype=aSourceType&lt;BR /&gt;&lt;BR /&gt;| transaction transaction_identifier startswith="START" endswith="COMPLETED OK"&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;| table startTimeRaw, endTimeRaw&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;The transaction_identifier has to be a value that is found in all relevant events and specific to that instance.&lt;BR /&gt;For example, if you want to track a purchase then the transaction_identifier could be the ID of the transaction.&lt;BR /&gt;Or if you want to track the session of a user you could use the username or the user's ID as the transaction_identifier.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2022 13:14:30 GMT</pubDate>
    <dc:creator>FelixLeh</dc:creator>
    <dc:date>2022-09-23T13:14:30Z</dc:date>
    <item>
      <title>How to Capture &amp; Compare _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614225#M213445</link>
      <description>&lt;P&gt;I am performing two searches in an attempt to calculate the duration, but am having some issues.&lt;/P&gt;
&lt;P&gt;Here is what I have working so far. Im getting results but they are in two different rows when I see results, I was expecting for them to be in one row to be used to calculate the duration ?&lt;/P&gt;
&lt;P&gt;What am I missing...&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN&gt;index=anIndex sourcetype=aSourceType (aString1 AND "START of script")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN&gt;| eval startTimeRaw=_time&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN&gt;| append [search index=anIndex sourcetype=aSourceType (aString1 AND "COMPLETED OK")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN&gt;| eval endTimeRaw=_time ]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=""&gt;&lt;SPAN&gt;| table startTimeRaw, endTimeRaw&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 15:43:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614225#M213445</guid>
      <dc:creator>sjringo</dc:creator>
      <dc:date>2022-09-23T15:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614249#M213447</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You should avoid to use append if possible. In this case you could try e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=anIndex sourcetype=aSourceType aString1 ("START of script" OR "COMPLETED OK")
| eval startTimeRaw = if (match(_raw, "START of script"), _time, null()),
       endTimeRaw   = if (match(_raw, "COMPLETED OK"), _time, null())
| stats range(_time) as duration values(startTimeRaw) as startTimeRaw values(endTimeRaw) as endTimeRaw by &amp;lt;some id for transaction&amp;gt;
| eval durationHuman = tostring (duration, "duration")
| table startTimeRaw, endTimeRaw&lt;/LI-CODE&gt;&lt;P&gt;Use in by your field which indentify that transaction.&lt;/P&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 06:48:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614249#M213447</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2022-09-23T06:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614302#M213456</link>
      <description>&lt;P&gt;Two follow up questions.&lt;/P&gt;&lt;P&gt;1)&amp;nbsp; Even though you suggest not using append, why does it not work ?&amp;nbsp; I have a working example using appendcols and assumed append would work similar.&amp;nbsp; In the appendcols example I use: " | stats count as X " for the first query variable then " | stats count as Y " for the second variable and then use X &amp;amp; Y to calculate a percentage.&amp;nbsp; But for this example trying to use eval instead of stats&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) The example makes sense up to "by &amp;lt;some id for transaction&amp;gt;".&amp;nbsp; What am I trying to reference here ?&amp;nbsp; From the search I have two events and two variables (startTimeRaw &amp;amp; endTimeRaw).&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 13:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614302#M213456</guid>
      <dc:creator>sjringo</dc:creator>
      <dc:date>2022-09-23T13:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614309#M213462</link>
      <description>&lt;P&gt;You could try the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;index=anIndex sourcetype=aSourceType&lt;BR /&gt;&lt;BR /&gt;| transaction transaction_identifier startswith="START" endswith="COMPLETED OK"&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;| table startTimeRaw, endTimeRaw&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;The transaction_identifier has to be a value that is found in all relevant events and specific to that instance.&lt;BR /&gt;For example, if you want to track a purchase then the transaction_identifier could be the ID of the transaction.&lt;BR /&gt;Or if you want to track the session of a user you could use the username or the user's ID as the transaction_identifier.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 13:14:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614309#M213462</guid>
      <dc:creator>FelixLeh</dc:creator>
      <dc:date>2022-09-23T13:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614341#M213479</link>
      <description>&lt;P&gt;For this example there is no unique piece of data that identifies the unique start/end time on a per day basis.&amp;nbsp; It is the same job that runs every day and its the same job name and same start and stop entries every day.&lt;/P&gt;&lt;P&gt;Is there a way to make the date the unique identifier as I eventually want to show results by day over time?&lt;/P&gt;&lt;P&gt;I have this working when I run for a timerange of 'today' but it does not work when I run for more than one day. i.e. 'week to date'&lt;/P&gt;&lt;P&gt;Your example was missing 'aJobName' as I am scanning many .log files for many jobs but am currently only interested in one to get something working.&lt;/P&gt;&lt;P&gt;index=anIndex sourcetype=aSourcetype aJobName ("START of script" OR "COMPLETED OK")&lt;/P&gt;&lt;P&gt;| eval startTimeRaw = if (match(_raw, "START of script"), _time, null()), endTimeRaw&amp;nbsp;&amp;nbsp; = if (match(_raw, "COMPLETED OK"), _time, null())&lt;/P&gt;&lt;P&gt;| stats range(_time) as duration values(startTimeRaw) as startTimeRaw values(endTimeRaw) as endTimeRaw by host&lt;/P&gt;&lt;P&gt;| eval duration = tostring (duration, "duration")&lt;/P&gt;&lt;P&gt;| table host, duration&lt;/P&gt;&lt;P&gt;The results for a time range of today returns results like:&lt;/P&gt;&lt;P&gt;Host Duration&lt;BR /&gt;server1 00:17:41&lt;/P&gt;&lt;P&gt;When I run for week to date I get the following results:&lt;BR /&gt;Host Duration&lt;BR /&gt;server1 1+00:52:02&lt;/P&gt;&lt;P&gt;I currently only have two days of data in Splunk but I think what is happening is that each query is returning two events, which is also why in my results I only have one row instead of two (one for 9/23 and one for 9/22) but I dont know how to change the above query or approach to be able to show duration over time on a daily basis which I eventually want to dump into a timechart to show duration over time.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 15:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614341#M213479</guid>
      <dc:creator>sjringo</dc:creator>
      <dc:date>2022-09-23T15:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614371#M213493</link>
      <description>&lt;P&gt;Group it by date.&lt;/P&gt;&lt;P&gt;index=anIndex sourcetype=aSourcetype aJobName ("START of script" OR "COMPLETED OK")&lt;BR /&gt;| eval startTimeRaw = if (match(_raw, "START of script"), _time, null()), endTimeRaw = if (match(_raw, "COMPLETED OK"), _time, null())&lt;BR /&gt;&lt;STRONG&gt;| eval event_date=strftime(_time,"%Y-%m-%d")&lt;/STRONG&gt;&lt;BR /&gt;| stats range(_time) as duration values(startTimeRaw) as startTimeRaw values(endTimeRaw) as endTimeRaw by &lt;STRONG&gt;event_date&amp;nbsp;&lt;/STRONG&gt;host&lt;BR /&gt;| eval duration = tostring (duration, "duration")&lt;BR /&gt;| table host, duration&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 18:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614371#M213493</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-09-23T18:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing &amp; Comparing _time from two searches using append ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614372#M213494</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229056"&gt;@FelixLeh&lt;/a&gt;&amp;nbsp;said, usually there must be some transaction identified which bind those event to the same physical event. You said that in this case it is a day. So we can do it by this way&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=anIndex sourcetype=aSourceType aString1 ("START of script" OR "COMPLETED OK")
| eval startTimeRaw = if (match(_raw, "START of script"), _time, null()),
       endTimeRaw   = if (match(_raw, "COMPLETED OK"), _time, null())
| bin span=1d _time as trcId
| stats range(_time) as duration values(startTimeRaw) as startTimeRaw values(endTimeRaw) as endTimeRaw by trcId
| eval durationHuman = tostring (duration, "duration")
| table trcId, startTimeRaw, endTimeRaw&lt;/LI-CODE&gt;&lt;P&gt;This divide events to 1 day slots and within those slots it calculate duration between start and end events. Probably you need to check that duration &amp;gt; 0 and if need take abs for it to get it right direction.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 18:48:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Capture-amp-Compare-time-from-two-searches-using-append/m-p/614372#M213494</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2022-09-23T18:48:17Z</dc:date>
    </item>
  </channel>
</rss>

