<?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 get time between events during a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409434#M118124</link>
    <description>&lt;P&gt;index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log"  "&lt;EM&gt;Source Message Received" "&lt;/EM&gt;_TEST01*" | xmlkv | table &lt;STRONG&gt;userId&lt;/STRONG&gt;,  _time&lt;/P&gt;

&lt;P&gt;the previous query works it gets all the userId and the initial time&lt;/P&gt;

&lt;P&gt;now I want to do something like this : &lt;/P&gt;

&lt;P&gt;for each userId &lt;BR /&gt;
index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log" "&lt;EM&gt;sent&lt;/EM&gt;" "&lt;EM&gt;_TEST01&lt;/EM&gt;" &lt;STRONG&gt;userId&lt;/STRONG&gt; | top limit=1 _time | table userId, ( _time2 - _time)&lt;/P&gt;

&lt;P&gt;_time2 is the the time when it was sent &lt;BR /&gt;
_time is the time we received the id &lt;BR /&gt;
userId : value of the xml tag&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:12:06 GMT</pubDate>
    <dc:creator>ayela</dc:creator>
    <dc:date>2020-09-29T20:12:06Z</dc:date>
    <item>
      <title>How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409431#M118121</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;

&lt;P&gt;Recently I faced some issues when I try to do an advance search.&lt;BR /&gt;
My problem : I need to create table that contains : id | duration&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;I search for the first appearance keyword and get the time.
Example : Received 115sd65sa25sa. 115sd65sa25sa is my id and Received  is my keyword let say the variable a = _time.&lt;/LI&gt;
&lt;LI&gt;Now for each id I want to search when it was sent (I also have a keyword for that) Example : Sent115sd65sa25sa b=_time&lt;/LI&gt;
&lt;LI&gt;So at the end I should have a table that contains the id and b-a &lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I tried to use different techniques like map and sub-search but it doesn't seem to work. &lt;/P&gt;

&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 02:24:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409431#M118121</guid>
      <dc:creator>ayela</dc:creator>
      <dc:date>2018-06-26T02:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409432#M118122</link>
      <description>&lt;P&gt;Hi @ayela ,&lt;BR /&gt;
Do you have sample events for both received and sent?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 02:38:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409432#M118122</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-26T02:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409433#M118123</link>
      <description>&lt;P&gt;I used my imagination to try to figure out what you want to achieve, so here's a sample of query it may help you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval id="Received", value="115sd65sa25sa", _time=relative_time(_time, "-2min")
| append
[| makeresults
| eval id="Sent", value="115sd65sa25sa"]
| stats list(id) as id,list(_time) as "time" by value 
| eval a = mvindex(time, 0) 
| eval b = mvindex(time, 1) 
| eval diff=b-a
| eval diff = tostring(diff, "duration")
| fields - id, time,a,b
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jun 2018 03:48:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409433#M118123</guid>
      <dc:creator>amiftah</dc:creator>
      <dc:date>2018-06-26T03:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409434#M118124</link>
      <description>&lt;P&gt;index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log"  "&lt;EM&gt;Source Message Received" "&lt;/EM&gt;_TEST01*" | xmlkv | table &lt;STRONG&gt;userId&lt;/STRONG&gt;,  _time&lt;/P&gt;

&lt;P&gt;the previous query works it gets all the userId and the initial time&lt;/P&gt;

&lt;P&gt;now I want to do something like this : &lt;/P&gt;

&lt;P&gt;for each userId &lt;BR /&gt;
index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log" "&lt;EM&gt;sent&lt;/EM&gt;" "&lt;EM&gt;_TEST01&lt;/EM&gt;" &lt;STRONG&gt;userId&lt;/STRONG&gt; | top limit=1 _time | table userId, ( _time2 - _time)&lt;/P&gt;

&lt;P&gt;_time2 is the the time when it was sent &lt;BR /&gt;
_time is the time we received the id &lt;BR /&gt;
userId : value of the xml tag&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409434#M118124</guid>
      <dc:creator>ayela</dc:creator>
      <dc:date>2020-09-29T20:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409435#M118125</link>
      <description>&lt;P&gt;Thank you for responding.&lt;/P&gt;

&lt;P&gt;Sorry if it was not clear.&lt;/P&gt;

&lt;P&gt;here's an example pf the query I try to do &lt;/P&gt;

&lt;P&gt;index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log" "Source Message Received" "_TEST01*" | xmlkv | table &lt;STRONG&gt;userId&lt;/STRONG&gt;, _time&lt;/P&gt;

&lt;P&gt;the previous query works it gets all the userId(from the xml) and the initial time&lt;/P&gt;

&lt;P&gt;now I want to do something like this :&lt;/P&gt;

&lt;P&gt;for each userId &lt;BR /&gt;
index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log" "sent" "_TEST01" &lt;STRONG&gt;userId&lt;/STRONG&gt; | top limit=1 _time | table &lt;STRONG&gt;userId&lt;/STRONG&gt;, ( _time2 - _time)&lt;/P&gt;

&lt;P&gt;_time2 is the the time when it was sent &lt;BR /&gt;
_time is the time we received the id &lt;BR /&gt;
userId : value of the xml tag&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:12:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409435#M118125</guid>
      <dc:creator>ayela</dc:creator>
      <dc:date>2020-09-29T20:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409436#M118126</link>
      <description>&lt;P&gt;Hi @ayela ,&lt;/P&gt;

&lt;P&gt;Try this and let me know what's missing&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="c" sourcetype="flox:app" laas_env=dev laas_file="/var/tmp/test/logs/dev.log" ("Source Message Received" OR "sent")
|eval startime=if(searchmatch("Source Message Received"),_time,null())
|eval endtime=if(searchmatch("sent"),_time,null())
|table _time,startime,endtime,userId
|where (startime!="" OR endtime!="")
|stats latest(startime) as start,latest(endtime) as end by userId
|eval time_diff=end-start
|table userId,time_diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jun 2018 02:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409436#M118126</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-06-27T02:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get time between events during a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409437#M118127</link>
      <description>&lt;P&gt;THANK YOU !!!! &lt;BR /&gt;
you just misspelled starttime but thank you very much !! &lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 16:42:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-time-between-events-during-a-search/m-p/409437#M118127</guid>
      <dc:creator>ayela</dc:creator>
      <dc:date>2018-06-27T16:42:46Z</dc:date>
    </item>
  </channel>
</rss>

