<?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: Join two rows and compare fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559285#M92511</link>
    <description>&lt;P&gt;It looks like the timestamp field is multi-valued.&amp;nbsp; The &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; function doesn't work with multi-valued fields.&amp;nbsp; Use &lt;FONT face="courier new,courier"&gt;mvindex&lt;/FONT&gt; to select one of the values or visit how the timestamp field is created to avoid multi-values.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 15:42:58 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2021-07-13T15:42:58Z</dc:date>
    <item>
      <title>Join two rows and compare fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559266#M92507</link>
      <description>&lt;P&gt;I feel i'm so close, but can't quite make it work. I've tried map and am now trying a sub search (I think it's a sub search). I'm trying to get the time difference between two events, but now using the "_time" field, instead using a timestamp field of my own. My events look something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; action: "start",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;correlationId:"_GUID_",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; timestamp: "&lt;SPAN&gt;2021-07-13T03:44:46.100Z&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; action: "end",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;correlationId:"_GUID_",&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; timestamp: "&lt;SPAN class="t string"&gt;2021-07-13T03:44:46.260Z&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And my query so far is&lt;BR /&gt;&lt;BR /&gt;index=* action=start&lt;BR /&gt;| eval start_time=timestamp&lt;BR /&gt;| join correlationId [ search index=action=end | eval end_time=timestamp ]&lt;BR /&gt;| eval timeTaken=end_time-start_time&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But&amp;nbsp;timeTaken is never populated. It seams my `timestamp` field has a "none" in it as well as a timestamp, but i'm not sure why as the raw text does not have any spaces or anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried a selfjoin, that overwrite the first `timestamp` with the second one, and a map, which came back with no results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:32:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559266#M92507</guid>
      <dc:creator>Peely</dc:creator>
      <dc:date>2021-07-13T13:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Join two rows and compare fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559270#M92508</link>
      <description>&lt;P&gt;You can't do math on timestamp strings because they're not numbers.&amp;nbsp; Convert them to integers using &lt;FONT face="courier new,courier"&gt;strptime()&lt;/FONT&gt; and then do the math.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* action=start
| eval start_time=timestamp
| join correlationId [ search index=action=end | eval end_time=timestamp ]
| eval endTime=strptime(end_time,"%Y-%m-%dT%H:%M:%S.%3N%Z"), startTime=strptime(start_time,"%Y-%m-%dT%H:%M:%S.%3N%Z")
| eval timeTaken=endTime-startTime&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559270#M92508</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-07-13T13:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Join two rows and compare fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559276#M92510</link>
      <description>&lt;P&gt;Ok cool, I didn't know that! So I think that takes me a step closer but I'm still not getting a value for `timeTaken` in the result. I think my input timestamps have multiple values (though they shouldn't), would that effect it? See attached a screenshot of the Splunk GUI showing one of the timestamps on one of the input events.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 14:33:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559276#M92510</guid>
      <dc:creator>Peely</dc:creator>
      <dc:date>2021-07-13T14:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Join two rows and compare fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559285#M92511</link>
      <description>&lt;P&gt;It looks like the timestamp field is multi-valued.&amp;nbsp; The &lt;FONT face="courier new,courier"&gt;strptime&lt;/FONT&gt; function doesn't work with multi-valued fields.&amp;nbsp; Use &lt;FONT face="courier new,courier"&gt;mvindex&lt;/FONT&gt; to select one of the values or visit how the timestamp field is created to avoid multi-values.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 15:42:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559285#M92511</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-07-13T15:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Join two rows and compare fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559415#M92524</link>
      <description>&lt;P&gt;`mvindex` was the missing piece! Thank you very much. My final query was in the form of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=*(action=start) 
| eval singleTimestamp=mvindex(timestamp, 1) | eval start_time=singleTimestamp 
| join correlationId
    [ search index=* action=end   | eval singleTimestamp=mvindex(timestamp, 1) | eval end_time=singleTimestamp  ]
| eval endTime=strptime(end_time,"%Y-%m-%dT%H:%M:%S.%3N%Z"), startTime=strptime(start_time,"%Y-%m-%dT%H:%M:%S.%3N%Z")
| eval timeTaken=floor((endTime-startTime)*1000)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 13:34:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Join-two-rows-and-compare-fields/m-p/559415#M92524</guid>
      <dc:creator>Peely</dc:creator>
      <dc:date>2021-07-14T13:34:12Z</dc:date>
    </item>
  </channel>
</rss>

