<?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 How to extract information from two rows in a search result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147545#M185320</link>
    <description>&lt;P&gt;Hi experts,&lt;/P&gt;

&lt;P&gt;I am trying to find a way of extracting information out of a search result and combining this information with another row. It's pretty hard to explain, so let me show you what I mean:&lt;/P&gt;

&lt;P&gt;Search: &lt;STRONG&gt;index=idx LogType="Locations"&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time | Latitude |Longitude&lt;/STRONG&gt;&lt;BR /&gt;
13:27:00 | 52.111 | 17.111&lt;BR /&gt;
13:30:00 | 52.222 | 17.222&lt;BR /&gt;
13:33:00 | 52.333 | 17.333&lt;BR /&gt;
13:36:00 | 52.444 | 17.444&lt;/P&gt;

&lt;P&gt;This is the basic search I got. Now I would like to calculate the distance between each of the result rows. I found a plugin called haversine (&lt;A href="https://splunkbase.splunk.com/app/936/#/overview"&gt;https://splunkbase.splunk.com/app/936/#/overview&lt;/A&gt;) which calculates the distance between two geo locations, so that is not really the problem, but what I'm really struggling with is to combine two rows of this search. &lt;/P&gt;

&lt;P&gt;Ultimately, in the above example it should calculate three distances, dist(52.444, 17.444 -&amp;gt; 52.333, 17.333), dist(52.333, 17.333 -&amp;gt; 52.222, 17.222) and dist(52.222, 17.222 -&amp;gt; 52.111, 17.111).&lt;/P&gt;

&lt;P&gt;So the final result could look like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time | Distance&lt;/STRONG&gt;&lt;BR /&gt;
13:36:00 | 5000&lt;BR /&gt;
13:33:00 | 4800&lt;BR /&gt;
13:30:00 | 4600&lt;/P&gt;

&lt;P&gt;Does anyone have an idea how something like this would be possible? &lt;/P&gt;

&lt;P&gt;Thanks a lot,&lt;BR /&gt;
Christian&lt;/P&gt;</description>
    <pubDate>Mon, 20 Apr 2015 07:57:30 GMT</pubDate>
    <dc:creator>MemoreX42</dc:creator>
    <dc:date>2015-04-20T07:57:30Z</dc:date>
    <item>
      <title>How to extract information from two rows in a search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147545#M185320</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;

&lt;P&gt;I am trying to find a way of extracting information out of a search result and combining this information with another row. It's pretty hard to explain, so let me show you what I mean:&lt;/P&gt;

&lt;P&gt;Search: &lt;STRONG&gt;index=idx LogType="Locations"&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Result:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time | Latitude |Longitude&lt;/STRONG&gt;&lt;BR /&gt;
13:27:00 | 52.111 | 17.111&lt;BR /&gt;
13:30:00 | 52.222 | 17.222&lt;BR /&gt;
13:33:00 | 52.333 | 17.333&lt;BR /&gt;
13:36:00 | 52.444 | 17.444&lt;/P&gt;

&lt;P&gt;This is the basic search I got. Now I would like to calculate the distance between each of the result rows. I found a plugin called haversine (&lt;A href="https://splunkbase.splunk.com/app/936/#/overview"&gt;https://splunkbase.splunk.com/app/936/#/overview&lt;/A&gt;) which calculates the distance between two geo locations, so that is not really the problem, but what I'm really struggling with is to combine two rows of this search. &lt;/P&gt;

&lt;P&gt;Ultimately, in the above example it should calculate three distances, dist(52.444, 17.444 -&amp;gt; 52.333, 17.333), dist(52.333, 17.333 -&amp;gt; 52.222, 17.222) and dist(52.222, 17.222 -&amp;gt; 52.111, 17.111).&lt;/P&gt;

&lt;P&gt;So the final result could look like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;_time | Distance&lt;/STRONG&gt;&lt;BR /&gt;
13:36:00 | 5000&lt;BR /&gt;
13:33:00 | 4800&lt;BR /&gt;
13:30:00 | 4600&lt;/P&gt;

&lt;P&gt;Does anyone have an idea how something like this would be possible? &lt;/P&gt;

&lt;P&gt;Thanks a lot,&lt;BR /&gt;
Christian&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 07:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147545#M185320</guid>
      <dc:creator>MemoreX42</dc:creator>
      <dc:date>2015-04-20T07:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract information from two rows in a search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147546#M185321</link>
      <description>&lt;P&gt;The way to go when you want to compare two (or more) rows is &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/Streamstats"&gt;streamstats&lt;/A&gt;. I would imagine that you could set &lt;CODE&gt;window=2&lt;/CODE&gt; and use &lt;CODE&gt;last()&lt;/CODE&gt; to get the value from the previous row (don't forget to set &lt;CODE&gt;current=false&lt;/CODE&gt; for this to work), then input those two into haversine.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 08:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147546#M185321</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-04-20T08:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract information from two rows in a search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147547#M185322</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;used your example data i used &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=temp sourcetype=distance | 
streamstats current=f last(Longitude) as lastLongitude last(Latitude) as lastLatitude |
eval lastlocation= lastLatitude  + " , " + lastLongitude | 
eval currlocation = Latitude  + " , " + Longitude |
search lastlocation=* AND currlocation=* |
haversine originField=lastlocation currlocation outputField=distance | 
table _time lastlocation currlocation distance
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;output is:&lt;/P&gt;

&lt;P&gt;_time   lastlocation    currlocation    distance&lt;BR /&gt;
2015-04-19 13:33:00     52.444 , 17.444     52.333 , 17.333     14.459705438259151&lt;BR /&gt;
2015-04-19 13:30:00     52.333 , 17.333     52.222 , 17.222     14.469574885347384&lt;BR /&gt;
2015-04-19 13:27:00     52.222 , 17.222     52.111 , 17.111     14.47944752893998&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 09:37:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-information-from-two-rows-in-a-search-result/m-p/147547#M185322</guid>
      <dc:creator>schose</dc:creator>
      <dc:date>2015-04-20T09:37:15Z</dc:date>
    </item>
  </channel>
</rss>

