<?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: Why does appendcols cause a search to produce different results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327112#M175328</link>
    <description>&lt;P&gt;If you have same date range why would you want to do appendcols? Please provide context.&lt;/P&gt;

&lt;P&gt;In any case if your time for Exit search is shifted by 3 days you can either do &lt;CODE&gt;_time=(_time-3*24*60*60)&lt;/CODE&gt;&lt;BR /&gt;
or else also try including earliest and latest dates directly in base search for both correlated search.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2017 08:47:22 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-02-28T08:47:22Z</dc:date>
    <item>
      <title>Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327111#M175327</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I have an index of events, each of which has an &lt;CODE&gt;enter&lt;/CODE&gt; and &lt;CODE&gt;exit&lt;/CODE&gt; timestamp where &lt;CODE&gt;_time&lt;/CODE&gt; is associated to the former.&lt;/P&gt;

&lt;P&gt;My first search is very simple and shows the &lt;CODE&gt;enter&lt;/CODE&gt; daily frequency:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
| timechart span=1d count as EnterCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This produces the following table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,EnterCount
2016-08-08,0
2016-08-09,16
2016-08-10,20
2016-08-11,23
2016-08-12,13
2016-08-13,2
2016-08-14,0
2016-08-15,0
2016-08-16,11
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then have another search that shows the &lt;CODE&gt;exit&lt;/CODE&gt; daily frequency:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
| eval _time = strptime(Exit, "%Y-%m-%d %H:%M:%S")
| timechart span=1d count as ExitCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This produces the following table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,ExitCount
2016-08-08,1
2016-08-09,4
2016-08-10,9
2016-08-11,16
2016-08-12,4
2016-08-13,0
2016-08-14,0
2016-08-15,0
2016-08-16,4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In order to chart this relationship between &lt;CODE&gt;enter&lt;/CODE&gt; and &lt;CODE&gt;exit&lt;/CODE&gt;, I use &lt;CODE&gt;appendcols&lt;/CODE&gt; to put them together:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
| timechart span=1d count as EnterCount
| appendcols [ search index=my_index
 | eval _time = strptime(Exit, "%Y-%m-%d %H:%M:%S")
 | timechart span=1d count as ExitCount ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The resulting table, however, displays incorrect values for &lt;CODE&gt;ExitCount&lt;/CODE&gt; by bringing the results forward by 3 days:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,EnterCount,ExitCount
2016-08-08,0,16
2016-08-09,16,4
2016-08-10,20,0
2016-08-11,23,0
2016-08-12,13,0
2016-08-13,2,4
2016-08-14,0,10
2016-08-15,0,13
2016-08-16,11,9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Why does this happen, and what can I do to ensure that the correct association is being made?&lt;/P&gt;

&lt;P&gt;Thank you and best regards,&lt;/P&gt;

&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 08:05:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327111#M175327</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-02-28T08:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327112#M175328</link>
      <description>&lt;P&gt;If you have same date range why would you want to do appendcols? Please provide context.&lt;/P&gt;

&lt;P&gt;In any case if your time for Exit search is shifted by 3 days you can either do &lt;CODE&gt;_time=(_time-3*24*60*60)&lt;/CODE&gt;&lt;BR /&gt;
or else also try including earliest and latest dates directly in base search for both correlated search.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 08:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327112#M175328</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-02-28T08:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327113#M175329</link>
      <description>&lt;P&gt;Thanks for the response!&lt;/P&gt;

&lt;P&gt;I need &lt;CODE&gt;appendcols&lt;/CODE&gt; because I am putting two different metrics into the same table.  Since they both have the same range I can easily do this, but for some reason they are being matched incorrectly.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 09:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327113#M175329</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-02-28T09:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327114#M175330</link>
      <description>&lt;P&gt;Do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index 
| bin _time span=1d 
| eval exit_time = strptime(Exit, "%Y-%m-%d %H:%M:%S") 
| bin exit_time span=1d | multireport
[| stats count AS EnterCount by _time]
[| stats count AS ExitCount by exit_time | rename exit_time AS _time]
| stats values(*) AS * BY _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 17:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327114#M175330</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-28T17:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327115#M175331</link>
      <description>&lt;P&gt;This part produces random test data, with only the _time and exit_time mattering.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start="01/25/2017:23:00:00" end="01/27/2017:01:00:00" increment=23m 
| append[| gentimes start="01/26/2017:03:00:00" end="01/26/2017:21:00:00" increment=47m ]
| append[| gentimes start="01/26/2017:01:17:00" end="01/26/2017:23:18:00" increment=21m ]
| eval _time = starttime | table _time 
| eval rand1=random() | eval rand2=substr(rand1,1,5) 
| eval exit_time = _time + tonumber(rand2)
| table _time exit_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This part separates the _time and exit_time into records by type, and reports on the counts&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Times ="enter="._time." exit=".exit_time
| table Times |  makemv Times | mvexpand Times 
| makemv delim="=" Times | eval type=mvindex(Times,0),_time=mvindex(Times,1) 
| table _time, type
| bin _time span=1d 
| chart count over _time by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Resulting in this -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time         enter     exit      
1/25/2017     3         0         
1/26/2017     149       85        
1/27/2017     2         69        
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327115#M175331</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T13:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327116#M175332</link>
      <description>&lt;P&gt;@andrewtobec...Did you try any of the options provided here? Since you had told time shifting by 3 days, I had suggested correcting time in inner query by 3 days... There are two other answers without use of appendcols, can you try them and confirm?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 05:30:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327116#M175332</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-01T05:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327117#M175333</link>
      <description>&lt;P&gt;In one of my &lt;A href="https://answers.splunk.com/answers/504805/why-does-my-chart-lose-interactivity-with-a-search.html"&gt;other questions&lt;/A&gt; I was given the suggestion by @rjthibod to work with the &lt;CODE&gt;chart&lt;/CODE&gt; and &lt;CODE&gt;append&lt;/CODE&gt; functions (I had since found a solution using &lt;CODE&gt;join&lt;/CODE&gt; which I was told isn't the most efficient way of doing things).  The following code works perfectly:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
| chart count as EnterCount over _time span=1d
| append 
 [ 
  search index=my_index
  | eval _time = strptime(Exit, "%Y-%m-%d %H:%M:%S")
  | chart count as ExitCount over _time span=1d ]
 ]
| timechart span=1d latest(*) as *
| fillnull value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks to @DalJeanis @woodcock and @niketnilay for their valuable input, I very much appreciate it.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 07:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327117#M175333</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-03-01T07:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327118#M175334</link>
      <description>&lt;P&gt;Thanks for the follow-up.  I have found a working solution and updated with the information.  Thank you for your support!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 07:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327118#M175334</guid>
      <dc:creator>andrewtrobec</dc:creator>
      <dc:date>2017-03-01T07:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why does appendcols cause a search to produce different results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327119#M175335</link>
      <description>&lt;P&gt;Our solutions also avoid using &lt;CODE&gt;append&lt;/CODE&gt; for the same reason that you should avoid &lt;CODE&gt;join&lt;/CODE&gt;: subsearch limits.  Your &lt;CODE&gt;append&lt;/CODE&gt;-based solution will break down with appended results &amp;gt; 50Kish.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 15:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-appendcols-cause-a-search-to-produce-different-results/m-p/327119#M175335</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-01T15:54:40Z</dc:date>
    </item>
  </channel>
</rss>

