<?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 I combine data from 2 seperate events . in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619347#M215256</link>
    <description>&lt;P&gt;Base search refers to the initial part of the query, for example, it may look like this:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;index=&amp;lt;index_name&amp;gt; sourcetype=&amp;lt;source_type&amp;gt;&lt;BR /&gt;| table _time&amp;nbsp;id, type, status, duration&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As long as you have the fields (&amp;nbsp;d, type, status, duration) available, this should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
| chart avg(duration) AS avg_duration BY type status
| eval LAST_VAL=0 
| foreach IN_QUEUE_* [
	| eval CURRENT_VAL=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; 
	| eval AVG_TIME_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;-LAST_VAL 
	| eval LAST_VAL=CURRENT_VAL
]
| table type AVG_TIME_*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2022 18:28:04 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-11-02T18:28:04Z</dc:date>
    <item>
      <title>How to combine data from 2 separate events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619159#M215194</link>
      <description>&lt;P&gt;I have the following scenario. An object transitions through multiple queues , I want to query the time spent in Queue 1 and group it by object type. Each object has unique id but it generates an event every time it transitions from queues. :&lt;/P&gt;
&lt;P&gt;Event 1:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id : 123&lt;/P&gt;
&lt;P&gt;type : type1&lt;/P&gt;
&lt;P&gt;status : IN_QUEUE_1&lt;/P&gt;
&lt;P&gt;duration : 100&lt;/P&gt;
&lt;P&gt;Event 1:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id : 123&lt;/P&gt;
&lt;P&gt;type : type1&lt;/P&gt;
&lt;P&gt;status : IN_QUEUE_2&lt;/P&gt;
&lt;P&gt;duration : 150&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;average_time_in_queue1&lt;/P&gt;
&lt;P&gt;type1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&lt;/P&gt;
&lt;P&gt;type2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;....&lt;/P&gt;
&lt;P&gt;type3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 02:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619159#M215194</guid>
      <dc:creator>Hyperlemon</dc:creator>
      <dc:date>2022-11-02T02:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619189#M215204</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
| chart avg(duration) AS avg_duration BY type status&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 18:26:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619189#M215204</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-01T18:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619231#M215218</link>
      <description>&lt;P&gt;i need to know the base search itself, its a bit complicated to figure out&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 06:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619231#M215218</guid>
      <dc:creator>Hyperlemon</dc:creator>
      <dc:date>2022-11-02T06:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619240#M215221</link>
      <description>&lt;P&gt;Can you illustrate your trial code for base search, as well as sample data (anonymize as necessary), then explain how it does not meet your requirements (when combined with&amp;nbsp;johnhuang's solution)? &amp;nbsp;Without data, it is next to impossible to know how to do base search.&lt;/P&gt;&lt;P&gt;For example, are the fields id, type, status, duration already extracted? &amp;nbsp;Or are your events contain key-value pair literals separated by colons (:) and your Splunk ingestion extracts nothing? &amp;nbsp;What is the physical meaning of the field "duration"? &amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;'s code assumes that "duration" signifies "&lt;SPAN&gt;the time spent in Queue." Can you confirm or deny?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 07:51:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619240#M215221</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-02T07:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619345#M215254</link>
      <description>&lt;P&gt;Yes that is correct I want the time spent inqueue. All the fields are extracted and can be used directly. Duration is basically the time elapsed since the object got created.&lt;/P&gt;&lt;P&gt;What i want to do is for each object i want to find the duration at which its state was "IN_QUEUE_2" and subtract it with the duration at which it was in state "IN_QUEUE_1", which gives me the time spent in the first queue, get the average of this value and group it by the object type. There will be many objects of each type , each object has a unique id and each object goes through state "IN_QUEUE1" -&amp;gt; "IN_QUEUE_2".&amp;nbsp;&lt;/P&gt;&lt;P&gt;So end data should look like :&lt;/P&gt;&lt;P&gt;Object type.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Avg inqueue time&lt;/P&gt;&lt;P&gt;type 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;/P&gt;&lt;P&gt;type 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 17:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619345#M215254</guid>
      <dc:creator>Hyperlemon</dc:creator>
      <dc:date>2022-11-02T17:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619347#M215256</link>
      <description>&lt;P&gt;Base search refers to the initial part of the query, for example, it may look like this:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;index=&amp;lt;index_name&amp;gt; sourcetype=&amp;lt;source_type&amp;gt;&lt;BR /&gt;| table _time&amp;nbsp;id, type, status, duration&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As long as you have the fields (&amp;nbsp;d, type, status, duration) available, this should work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
| chart avg(duration) AS avg_duration BY type status
| eval LAST_VAL=0 
| foreach IN_QUEUE_* [
	| eval CURRENT_VAL=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; 
	| eval AVG_TIME_&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;-LAST_VAL 
	| eval LAST_VAL=CURRENT_VAL
]
| table type AVG_TIME_*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 18:28:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619347#M215256</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-02T18:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to I combine data from 2 seperate events .</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619397#M215275</link>
      <description>&lt;P&gt;One key point (for outsiders) to digest the requirement is "&lt;SPAN&gt;Duration is basically the time elapsed since the object got created."&amp;nbsp;&lt;/SPAN&gt;I further speculate that you want to average across id. &amp;nbsp;Considering these, this may be what you wanted:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;status IN (IN_QUEUE_1, IN_QUEUE_2) ``` add any additional filters ```
| stats max(duration) as enter_queue2 min(duration) as enter_queue1 by id type
| eval duration_in_queue1 = enter_queue2 - enter_queue1
| stats avg(duration_in_queue1) as average_duration_in_queue1 by type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 05:01:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-data-from-2-separate-events/m-p/619397#M215275</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-03T05:01:34Z</dc:date>
    </item>
  </channel>
</rss>

