<?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: Delta between timestamp within a transaction search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16832#M2258</link>
    <description>&lt;P&gt;The coalesce adds the subsecond again to the _time result making Splunk think it is not in UTC format (e.g., 1276549400.543.543), which will keep you doing any more math upon it. The best I could come up with is to find deltas between any times in the transaction manually:&lt;/P&gt;

&lt;P&gt;sourcetype="my_message" req=43300 | eval timecopy=_time | transaction req mvlist="timecopy" | eval first=mvindex(timecopy,0) | eval second=mvindex(timecopy,1) | eval mydelta=second-first &lt;/P&gt;

&lt;P&gt;That works for specific queries, but it won't automate the query where you want to find all "mydelta" within a transaction &amp;gt; .xxx.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 09:14:36 GMT</pubDate>
    <dc:creator>ndoshi</dc:creator>
    <dc:date>2020-09-28T09:14:36Z</dc:date>
    <item>
      <title>Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16830#M2256</link>
      <description>&lt;P&gt;The transaction search command will automatically compute the duration from the first event to the last event within each grouping. I would like to create a new multivalue field which computes the difference in time between each event within a grouping. For example if I have&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_message |transaction req 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I might get this as one transaction event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mon Jun 14 17:03:20.543 EDT 2010 req=43300 hi there
Mon Jun 14 17:03:20.743 EDT 2010 req=43300 Another message
Mon Jun 14 17:03:20.845 EDT 2010 req=43300 status=invalid_request
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, I know the duration field for this would be set to 0.302 in this example. However, I would like time delta's between each subsequent event. In this example, I'd like a new multivalue field set to 0.200 and 0.102. If the number of events in the group had 4 entries, I'd have 3 time differences. If the number of events in the grouping had 5 entries, I'd have 4 time differences and so on. How can this be done?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 02:50:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16830#M2256</guid>
      <dc:creator>ndoshi</dc:creator>
      <dc:date>2010-07-03T02:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16831#M2257</link>
      <description>&lt;P&gt;I was thinking that you could use the &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Delta" rel="nofollow"&gt;delta&lt;/A&gt; command to build a list of time differences between events &lt;EM&gt;before&lt;/EM&gt; &lt;CODE&gt;transaction&lt;/CODE&gt;, however I don't think this will work because &lt;CODE&gt;delta&lt;/CODE&gt; is simply looking at each sequential events not sequential events for the same transaction necessarily.&lt;/P&gt;

&lt;P&gt;Here is another thought.  What if you simply make a copy of &lt;CODE&gt;_time&lt;/CODE&gt; before &lt;CODE&gt;transaction&lt;/CODE&gt;, that should give you a multi-valued field preserving all of your timestamps for the events within your transaction.  Then you may be able to find a way to calculate the deltas from there.&lt;/P&gt;

&lt;P&gt;You could try this and see how far it gets you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_message | eval timecopy=_time | transaction req mvlist="timecopy"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;This &lt;STRONG&gt;should&lt;/STRONG&gt; do the trick.   It's pretty ugly and you lose tons a fields in the process (you'll have to probably do some tweaking).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_message | eval timecopy=_time | transaction req mvlist=timecopy | eval txn_serial=mvindex(_serial,0) | eval txn_raw=_raw | fields + host source sourcetype timecopy txn_* duration | mvexpand timecopy | streamstats window=2 last(timecopy) as t1,first(timecopy) as t2 by txn_serial | eval timediff=t1-t2 | stats values(_time) as _time, values(txn_raw) as _raw, list(timediff) as timediff by txn_serial
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;Basic theory:&lt;/EM&gt;   We assign each transaction a unique number (based on the serial number of the first event within the transaction).  Then we blow apart the events into multiple events based on the &lt;CODE&gt;timecopy&lt;/CODE&gt; multivalued field.  (It's possible that &lt;CODE&gt;mvexpand&lt;/CODE&gt; squashes duplicate field values, so keep your eye out for that. It may or may not matter to your overall purpose.)  Then we use the &lt;CODE&gt;streamstats&lt;/CODE&gt; to grab the two side-by-side timestamp copies for a single transaction (that is know only associated together using the "txn_serial" value).  An eval is used to get the the diff between the two side-by-side timestamps.  (This part might not be quite right.  I didn't have very good data to test this with.)  Then we use a &lt;CODE&gt;stats&lt;/CODE&gt; command to try to pull it all back together.&lt;/P&gt;

&lt;P&gt;Unfortunately, due to the "stats" command (and probably a few others), Splunk displays the search output as a results table, when we would rather have it try to display it in "Event listing" mode, so you can't really see the raw event anymore (in other words, my attempt to save "_raw" and then restore it using &lt;CODE&gt;values(txn_raw) as _raw&lt;/CODE&gt; does quite do the trick.)&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt; It's quite possible that wrong values are being returned in this query.  It wouldn't surprise me if there are logical bugs that need to be squashed. I would reccomend that you rebuild this search step by step and confirm the data at even point.&lt;/P&gt;

&lt;P&gt;Best of luck.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 03:06:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16831#M2257</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-07-03T03:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16832#M2258</link>
      <description>&lt;P&gt;The coalesce adds the subsecond again to the _time result making Splunk think it is not in UTC format (e.g., 1276549400.543.543), which will keep you doing any more math upon it. The best I could come up with is to find deltas between any times in the transaction manually:&lt;/P&gt;

&lt;P&gt;sourcetype="my_message" req=43300 | eval timecopy=_time | transaction req mvlist="timecopy" | eval first=mvindex(timecopy,0) | eval second=mvindex(timecopy,1) | eval mydelta=second-first &lt;/P&gt;

&lt;P&gt;That works for specific queries, but it won't automate the query where you want to find all "mydelta" within a transaction &amp;gt; .xxx.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:14:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16832#M2258</guid>
      <dc:creator>ndoshi</dc:creator>
      <dc:date>2020-09-28T09:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16833#M2259</link>
      <description>&lt;P&gt;I'm not sure how you got the subseconds value in there twice, I wasn't seeing them on a test search I ran, so I added it on.  &lt;CODE&gt;timecopy&lt;/CODE&gt; should always be either integer or decimal format, that's weird.  I think splunk does some special behind the sceans voodoo with &lt;CODE&gt;_time&lt;/CODE&gt; which may explain this...  You probably want the subseconds, otherwise your difference will be 0 between all your events, at least in your example case.  (BTW.  "UTC" is a timezone, not a timestamp "format".  I think the therm your looking for is "unix epoch" timestamp, which is based on the UTC timezone.)&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 05:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16833#M2259</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-07-03T05:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16834#M2260</link>
      <description>&lt;P&gt;I tried it again and got the double-decimal thing to.  I dunno very weird.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 05:20:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16834#M2260</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-07-03T05:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16835#M2261</link>
      <description>&lt;P&gt;I added another more complete solution.  Good luck.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 05:53:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16835#M2261</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-07-03T05:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16836#M2262</link>
      <description>&lt;P&gt;First of all, I would be interested to know why something thinks they need this data, i.e., what are they going to do once they have every single delta? The specific use cases &lt;EM&gt;might&lt;/EM&gt; be much simpler and more efficient to solve than the general ones of getting every delta.&lt;/P&gt;

&lt;P&gt;But try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_message 
| eval etime=_time 
| transaction req 
| eval tr_id=mvindex(_serial,0) 
| mvexpand etime
| streamstats current=f global=f window=1 
    last(etime) as letime 
  by tr_id
| eval dtime=coalesce(etime-letime,0) 
| fields - letime,etime 
| eventstats 
    list(dtime) as dtime 
  by tr_id
| dedup tr_id
| fields - tr_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Instead of adding (and removing) a field &lt;CODE&gt;tr_id&lt;/CODE&gt;, you could use &lt;CODE&gt;req&lt;/CODE&gt; in your specific example, but if you had transactions where the id field wasn't unique and unitary, you need something like &lt;CODE&gt;tr_id&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 06:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16836#M2262</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-03T06:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16837#M2263</link>
      <description>&lt;P&gt;i didn't test with subseconds, so adjust the &lt;CODE&gt;eval etime&lt;/CODE&gt; as necessary.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 06:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16837#M2263</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-03T06:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16838#M2264</link>
      <description>&lt;P&gt;changed. old one worked, but this is probably more efficient.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2010 23:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16838#M2264</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-03T23:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Delta between timestamp within a transaction search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16839#M2265</link>
      <description>&lt;P&gt;Also see...&lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/questions/4381/can-splunk-help-me-further-analyze-refine-the-durations-of-my-transactions"&gt;http://answers.splunk.com/questions/4381/can-splunk-help-me-further-analyze-refine-the-durations-of-my-transactions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2011 03:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Delta-between-timestamp-within-a-transaction-search/m-p/16839#M2265</guid>
      <dc:creator>carasso</dc:creator>
      <dc:date>2011-01-04T03:10:28Z</dc:date>
    </item>
  </channel>
</rss>

