<?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: appendcols subsearch skewing timestamps in some circumstances in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529005#M149351</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;Yes, but I believe I countered the differing sort orders with the &lt;FONT face="courier new,courier"&gt;reverse&lt;/FONT&gt;?&lt;/P&gt;&lt;P&gt;I tried that but the &lt;FONT face="courier new,courier"&gt;resolve_time&lt;/FONT&gt; column is simply blank, unfortunately.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 16:39:29 GMT</pubDate>
    <dc:creator>benhooper</dc:creator>
    <dc:date>2020-11-11T16:39:29Z</dc:date>
    <item>
      <title>appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/528952#M149342</link>
      <description>&lt;P&gt;I'm working with a system where each event has its own creation timestamp (always the same) and modification timestamp.&lt;/P&gt;&lt;P&gt;Currently, I want to get the most recent resolved event to establish the latest modification time and then get the earliest resolved event in order to establish the actual resolve time which I've achieved with&lt;SPAN&gt;&amp;nbsp;the following search query:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=&amp;lt;index name&amp;gt; | where match(status, "resolved") | dedup 1 incident_id sortby -_time
| table incident_id, status, creation_time, resolve_time, modification_time
| appendcols [
    search index=&amp;lt;index name&amp;gt; | where match(status, "resolved") | dedup 1 incident_id sortby +_time
    | eval resolve_time = modification_time
    | reverse
    | table resolve_time ]
| eval modification_time = if(resolve_time == modification_time, "Unchanged", modification_time)
| table incident_id, status, creation_time, resolve_time, modification_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can be hard to visualise this so I've illustrated it below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020 ∕ 11 ∕ 11 10꞉36꞉25 - Search__Splunk_8.1.0_-_Google_Chrome.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11839i2DB93B7F26A7189D/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020 ∕ 11 ∕ 11 10꞉36꞉25 - Search__Splunk_8.1.0_-_Google_Chrome.png" alt="2020 ∕ 11 ∕ 11 10꞉36꞉25 - Search__Splunk_8.1.0_-_Google_Chrome.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;From the above screenshot, you can see that the incident with ID 1735 was initially resolved on 2020/11/06 at 11:56:27 but was modified twice, once at 11:57:54 and again at 15:02:42.&lt;/P&gt;&lt;P&gt;When the search only includes one post-resolution modification, this is exactly what's reported which can be seen in the following screenshot&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020 ∕ 11 ∕ 11 10꞉52꞉49 - Search__Splunk_8.1.0_-_Google_Chrome.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11841i0370B10D4D7EA246/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020 ∕ 11 ∕ 11 10꞉52꞉49 - Search__Splunk_8.1.0_-_Google_Chrome.png" alt="2020 ∕ 11 ∕ 11 10꞉52꞉49 - Search__Splunk_8.1.0_-_Google_Chrome.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, the strange thing is that, when there's a&amp;nbsp;&lt;STRONG&gt;second&lt;/STRONG&gt; post-resolution modification, the&amp;nbsp;timestamps&amp;nbsp;get skewed into the future - &lt;FONT face="courier new,courier"&gt;resolve_time&lt;/FONT&gt; is supposed to remain as &lt;FONT face="courier new,courier"&gt;2020/11/06 11:56:27.351&lt;/FONT&gt; but gets changed to &lt;FONT face="courier new,courier"&gt;2020/11/06 &lt;STRONG&gt;14:52:13.822&lt;/STRONG&gt;&lt;/FONT&gt;. This can be seen in the following screenshot:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020 ∕ 11 ∕ 11 11꞉00꞉18 - Search__Splunk_8.1.0_-_Google_Chrome.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11842iD68746991E811816/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020 ∕ 11 ∕ 11 11꞉00꞉18 - Search__Splunk_8.1.0_-_Google_Chrome.png" alt="2020 ∕ 11 ∕ 11 11꞉00꞉18 - Search__Splunk_8.1.0_-_Google_Chrome.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Through testing, I have:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Verified that the two searches work exactly as intended when copy and pasted into standalone searches.&lt;/LI&gt;&lt;LI&gt;Found that&amp;nbsp;&lt;STRONG&gt;all&amp;nbsp;&lt;/STRONG&gt;timestamps (&lt;FONT face="courier new,courier"&gt;_time&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;creation_time&lt;/FONT&gt;, and &lt;FONT face="courier new,courier"&gt;modification_time&lt;/FONT&gt;) within the &lt;FONT face="courier new,courier"&gt;appendcols&lt;/FONT&gt; subsearch are skewed.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Even more bizarrely, the timestamps that are outputted aren't mentioned anywhere else. It's almost as if they're a result of some kind of search-time calculation.&lt;/P&gt;&lt;P&gt;Why is this happening?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 11:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/528952#M149342</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-11-11T11:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529002#M149349</link>
      <description>&lt;P&gt;Be careful when using &lt;FONT face="courier new,courier"&gt;appendcols&lt;/FONT&gt;.&amp;nbsp; The results of the subsearch are added to the results of the main search without regard to context.&amp;nbsp; In other words, the first result of the subsearch is appended to the first result of the main search no matter what.&lt;/P&gt;&lt;P&gt;In the query here, the main search results are sorted in descending order by time whereas the subsearch is sorted in ascending order by time.&amp;nbsp; That would appear to be inviting an erroneous appending of a field.&lt;/P&gt;&lt;P&gt;When the number and sequence of events is not guaranteed to be the same in both the main and sub searches, don't use &lt;FONT face="courier new,courier"&gt;appendcols&lt;/FONT&gt;.&amp;nbsp; Try &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt;, instead, and use &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; to merge to two result sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=&amp;lt;index name&amp;gt; | where match(status, "resolved") | dedup 1 incident_id sortby -_time
| table incident_id, status, creation_time, resolve_time, modification_time
| append [
    search index=&amp;lt;index name&amp;gt; | where match(status, "resolved") | dedup 1 incident_id sortby +_time
    | eval resolve_time = modification_time
    | reverse
    | table resolve_time ]
| stats values(*) as * by incident_id
| eval modification_time = if(resolve_time == modification_time, "Unchanged", modification_time)
| table incident_id, status, creation_time, resolve_time, modification_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 16:07:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529002#M149349</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-11T16:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529005#M149351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;Yes, but I believe I countered the differing sort orders with the &lt;FONT face="courier new,courier"&gt;reverse&lt;/FONT&gt;?&lt;/P&gt;&lt;P&gt;I tried that but the &lt;FONT face="courier new,courier"&gt;resolve_time&lt;/FONT&gt; column is simply blank, unfortunately.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 16:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529005#M149351</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-11-11T16:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529018#M149354</link>
      <description>&lt;P&gt;Yes, the &lt;FONT face="courier new,courier"&gt;reverse&lt;/FONT&gt; should account for the different sort orders.&amp;nbsp; Still, one must be very careful about the exact results of the subsearch when using &lt;FONT face="courier new,courier"&gt;appendcols&lt;/FONT&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe I see the error in my previous query.&amp;nbsp; Please try this revision.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=&amp;lt;index name&amp;gt; | where match(status, "resolved") 
| stats earliest(resolve_time) as resolve_time, latest(resolve_time) as modification_time, first(status) as status, first(creation_time) as creation_time by incident_id
| eval modification_time = if(resolve_time == modification_time, "Unchanged", modification_time)
| table incident_id, status, creation_time, resolve_time, modification_time&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 11 Nov 2020 18:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529018#M149354</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-11T18:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529102#M149382</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks again but, unfortunately, a similar problem - the &lt;FONT face="courier new,courier"&gt;resolve_time&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;modification_time&lt;/FONT&gt; columns are blank.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 09:04:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529102#M149382</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-11-12T09:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529146#M149398</link>
      <description>&lt;P&gt;I'm not seeing where my mistake is.&amp;nbsp; When you look at the Events tab, do you see the resolve_time field?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 14:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529146#M149398</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-12T14:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529153#M149401</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;My apologies. I had a lot going on this morning so I ran your query without checking it properly.&lt;/P&gt;&lt;P&gt;The field &lt;FONT face="courier new,courier"&gt;resolve_time&lt;/FONT&gt; doesn't exist in the original events which explains what I was seeing so I've replaced both instances of &lt;FONT face="courier new,courier"&gt;(resolve_time)&lt;/FONT&gt; with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;(modification_time)&lt;/FONT&gt; and it appears to working perfectly&amp;nbsp;&lt;STRONG&gt;and&amp;nbsp;&lt;/STRONG&gt;it's significantly simpler! Thank you very much!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020 ∕ 11 ∕ 12 14꞉51꞉23 - Search__Splunk_8.1.0_-_Google_Chrome.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/11874i727D7512F23FB7B1/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020 ∕ 11 ∕ 12 14꞉51꞉23 - Search__Splunk_8.1.0_-_Google_Chrome.png" alt="2020 ∕ 11 ∕ 12 14꞉51꞉23 - Search__Splunk_8.1.0_-_Google_Chrome.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm still confused why my search was acting that way in those circumstances but at least I have a solution now.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 14:58:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529153#M149401</guid>
      <dc:creator>benhooper</dc:creator>
      <dc:date>2020-11-12T14:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: appendcols subsearch skewing timestamps in some circumstances</title>
      <link>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529159#M149405</link>
      <description>&lt;P&gt;If your problem is resolved, then please click the "Accept as Solution" button to help future readers.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 15:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/appendcols-subsearch-skewing-timestamps-in-some-circumstances/m-p/529159#M149405</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-12T15:37:21Z</dc:date>
    </item>
  </channel>
</rss>

