<?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: Transaction Question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295644#M161971</link>
    <description>&lt;P&gt;Thank you for your response. I tried this...&lt;/P&gt;

&lt;P&gt;I extracted the messages to the field "Restart_status"...&lt;/P&gt;

&lt;P&gt;host=ns2 I move from | transaction Restart_status startswith="I move from normal to communications-interrupted" endswith="I move from startup to normal" | sort 0 _time | streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" | eval duration=if(Restart_status="I move from startup to normal", _time-start_time, NULL)&lt;/P&gt;

&lt;P&gt;To no avail.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:43:38 GMT</pubDate>
    <dc:creator>justintaylor9</dc:creator>
    <dc:date>2020-09-29T18:43:38Z</dc:date>
    <item>
      <title>Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295638#M161965</link>
      <description>&lt;P&gt;Trying to calculate the duration between two log messages, have found many resources online but nothing seems to work quite right...&lt;/P&gt;

&lt;P&gt;This is what I am trying:&lt;/P&gt;

&lt;P&gt;host=ns2 I move from | transaction Restart_status startswith="I move from normal to communications-interrupted" endswith="I move from startup to normal" | timechart avg(duration) by Restart_status&lt;/P&gt;

&lt;P&gt;Basically I want to know how long it for the server to restart its DHCP service. I defined 'Restart_status' as a custom field.&lt;/P&gt;

&lt;P&gt;Currently this search ends up with 0 results.&lt;/P&gt;

&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:43:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295638#M161965</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2020-09-29T18:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295639#M161966</link>
      <description>&lt;P&gt;can you please provide examples of your events&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:37:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295639#M161966</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-03-28T16:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295640#M161967</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;3/28/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;10:22:43.000 AM &lt;BR /&gt;
Mar 28 10:22:43 ns2 dhcpd[5445]: failover peer ns1-ns2(1521650181p): I move from startup to normal&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host =  ns2 
source =    /var/log/splunk-data/splunk.log 
sourcetype =    infoblox:dhcp   

3/28/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;10:22:42.000 AM &lt;BR /&gt;
Mar 28 10:22:42 ns2 dhcpd[2911]: failover peer ns1-ns2(1521650181p): I move from communications-interrupted to startup&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host =  ns2 
source =    /var/log/splunk-data/splunk.log 
sourcetype =    infoblox:dhcp   

3/28/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;10:19:03.000 AM &lt;BR /&gt;
Mar 28 10:19:03 ns2 dhcpd[28860]: failover peer ns1-ns2(1521650181p): I move from normal to communications-interrupted&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host =  ns2 
source =    /var/log/splunk-data/splunk.log 
sourcetype =    infoblox:dhcp   

3/28/18
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;10:01:45.000 AM &lt;BR /&gt;
Mar 28 10:01:45 ns2 dhcpd[28860]: failover peer ns1-ns2(1521650181p): I move from communications-interrupted to normal&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host =  ns2 
source =    /var/log/splunk-data/splunk.log 
sourcetype =    infoblox:dhcp   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 16:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295640#M161967</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-28T16:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295641#M161968</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/104813"&gt;@justintaylor9&lt;/a&gt; what is the ID between events to be correlated? What is the Restart_Status value in the sample events you have provided, as you have used Restart_Status as ID field in your transaction?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:48:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295641#M161968</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T18:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295642#M161969</link>
      <description>&lt;P&gt;The use of the Splunk &lt;CODE&gt;transaction&lt;/CODE&gt; command requires a field that ties together the events, like a session_id or device_id, etc. It looks like your events don't have such a unifying field; instead, you want to assume that the time-based ordering of the fields always defines a transaction. We can do that. Assuming you've extracted the messages like "I move from communications-interrupted to normal" and "I move from communications-interrupted to startup" into a field called &lt;CODE&gt;msg&lt;/CODE&gt;, this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search collecting the events
| sort 0 _time 
| streamstats earliest(_time) AS start_time reset_after="(msg=\"I move from startup to normal\")"
| eval duration=if(msg="I move from startup to normal", _time-start_time, NULL)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The events that define the end of a transaction (events with &lt;CODE&gt;msg="I move from startup to normal"&lt;/CODE&gt;) will get a field called &lt;CODE&gt;duration&lt;/CODE&gt;, with the duration (in seconds) of the time between that particular event and the most recent event preceding it that contains &lt;CODE&gt;msg="I move from normal to communications-interrupted"&lt;/CODE&gt;. All events will also have a field called &lt;CODE&gt;start_time&lt;/CODE&gt;, which is the value of &lt;CODE&gt;_time&lt;/CODE&gt; for the most recent event marking the start of the pseudo-transaction.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295642#M161969</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T18:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295643#M161970</link>
      <description>&lt;P&gt;Restart_status is a field I extracted... it contains either 'I move from normal to communications-interrupted' or 'I move from startup to normal' which indicate the start and end of the restart process.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 18:14:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295643#M161970</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-28T18:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295644#M161971</link>
      <description>&lt;P&gt;Thank you for your response. I tried this...&lt;/P&gt;

&lt;P&gt;I extracted the messages to the field "Restart_status"...&lt;/P&gt;

&lt;P&gt;host=ns2 I move from | transaction Restart_status startswith="I move from normal to communications-interrupted" endswith="I move from startup to normal" | sort 0 _time | streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" | eval duration=if(Restart_status="I move from startup to normal", _time-start_time, NULL)&lt;/P&gt;

&lt;P&gt;To no avail.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:43:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295644#M161971</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2020-09-29T18:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295645#M161972</link>
      <description>&lt;P&gt;ID is supposed to be matching for the two events your are correlating. If  Restart_Status is not and ID your transaction will not work. So coming back to the question... What is the ID between each Start and End? Or is it every subsequent entry will be start and then end?&lt;/P&gt;

&lt;P&gt;Event before transaction or any other approach can be applied, could you please explain based on sample data provided as to how you know that the two events are far the same transaction i.e start and stop?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 18:21:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295645#M161972</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-28T18:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295646#M161973</link>
      <description>&lt;P&gt;Every subsequent entry will be start and then end.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 18:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295646#M161973</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-28T18:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295647#M161974</link>
      <description>&lt;P&gt;I think you mis-interpreted @elliotproebstel's answer.  This should clarify.  It uses &lt;CODE&gt;streamstats&lt;/CODE&gt; instead of &lt;CODE&gt;transaction&lt;/CODE&gt; because the latter does not perform well.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=ns2 "move from" | sort 0 _time | streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" | eval duration=if(Restart_status="I move from startup to normal", _time-start_time, NULL)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 18:25:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295647#M161974</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-03-28T18:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295648#M161975</link>
      <description>&lt;P&gt;Shouldn't it be like this:&lt;/P&gt;

&lt;P&gt;host=ns2 "move from" | sort 0 _time | streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" | eval duration=if(Restart_status="I move from normal to communications-interrupted", _time-start_time, NULL)&lt;/P&gt;

&lt;P&gt;This is still not working.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:43:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295648#M161975</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2020-09-29T18:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295649#M161976</link>
      <description>&lt;P&gt;No, your changes should yield duration values of 0. The search suggested by @richgalloway is what I intended. Can you tell us in what way it is not working? It is calculating the wrong value? Is it not giving any results at all? This will help us troubleshoot.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 19:46:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295649#M161976</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-28T19:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295650#M161977</link>
      <description>&lt;P&gt;It just returns with all of the events that match the base search "move from" ... without any calculations occurring. &lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295650#M161977</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-29T12:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295651#M161978</link>
      <description>&lt;P&gt;Hmm, interesting. Can you verify that the _time fields are properly extracted? Maybe try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=ns2 "move from"
| eval display_time=_time
| table _time display_time _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does that show you three columns? It should display the _time field as a human-readable timestamp, the display_time field as an epoch time string (a long number), and the raw text of the event. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:44:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295651#M161978</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2020-09-29T18:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295652#M161979</link>
      <description>&lt;P&gt;The time fields are indeed properly extracted. This search shows precisely what you specified, the three columns with the human-readable timestamp, the epoch, and the full event.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295652#M161979</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-29T14:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295653#M161980</link>
      <description>&lt;P&gt;The plot thickens! How about this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=ns2 "move from" 
| sort 0 _time 
| streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" 
| eval duration=if(Restart_status="I move from startup to normal", _time-start_time, NULL)
| table _time Restart_status start_time duration 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295653#M161980</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-29T14:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295654#M161981</link>
      <description>&lt;P&gt;Now we are in business. Duration is showing correct values, with the exception of one giant outlier. This should give me exactly what I need. Thank you guys so much for your help!!!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295654#M161981</guid>
      <dc:creator>justintaylor9</dc:creator>
      <dc:date>2018-03-29T14:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction Question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295655#M161982</link>
      <description>&lt;P&gt;Glad to help. Since we've solved it, I'd like to explain the difference between this final "test" and what we did before. All we added here was a &lt;CODE&gt;table&lt;/CODE&gt; command, which displays the results of the calculations front and center. Without the &lt;CODE&gt;table&lt;/CODE&gt; command, the fields were still being calculated, but you'd have to expand individual events to view the results. Give it a shot. Run this search query: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; host=ns2 "move from" 
 | sort 0 _time 
 | streamstats earliest(_time) AS start_time reset_after="(Restart_status=\"I move from startup to normal\")" 
 | eval duration=if(Restart_status="I move from startup to normal", _time-start_time, NULL)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And click to expand an event that contains "I move from startup to normal". You'll see the fields &lt;CODE&gt;start_time&lt;/CODE&gt; and &lt;CODE&gt;duration&lt;/CODE&gt; were hiding there under the covers. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You can change the final command (table, stats, etc.) to display exactly what you want to see.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 14:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Transaction-Question/m-p/295655#M161982</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-03-29T14:44:07Z</dc:date>
    </item>
  </channel>
</rss>

