<?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: Adding or removing the append command changes a previous calculated field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488383#M136439</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;index=machinedata_w05_sum app=Medienverbrauch medium="el.Energie" machine=Sema4 earliest=-30d 
    | stats avg(Verbrauch_elEnergie_pro_Stk) as avgliter 
    | fields avgliter 
    | eval avgliter=round(avgliter, 5)
| append [ search index=machinedata_w05 source=W05WTSema4IV320732 name=S3.Energiedaten.Wirkenergie_Tag OR name=S7.Prozessdaten.wst_gesamt earliest=@d 
| eval {name}=value 
| eval day = strftime(_time, "%d.%m.%Y") 
| rename S3.Energiedaten.Wirkenergie_Tag as elEnergie1
    S7.Prozessdaten.wst_gesamt as Stk 
| table _time elEnergie1 day Stk 
| filldown elEnergie1 
| autoregress elEnergie1 
| table _time elEnergie1 elEnergie1_p1 day Stk 
| where elEnergie1!="" OR elEnergie1_p1!="" OR Stk!="" 
| eval diff=elEnergie1_p1-elEnergie1 
| table _time elEnergie1 elEnergie1_p1 diff day Stk 
| where diff&amp;gt;0 OR Stk!="" 
| stats first(_time) as _time sum(diff) as elEnergie1 range(Stk) as Stk by day 
| where Stk!=0 
| eval elEnergie1Stk = round(elEnergie1/Stk, 5),
    elEnergie1=round(elEnergie1, 2) 
| table elEnergie1Stk elEnergie1 Stk 
| fields - _time 
| reverse]
| reverse
| filldown 
| eval abw = round((if(isnull(elEnergie1Stk), -1, elEnergie1Stk)-avgliter)/avgliter*100, 1) 
| table abw elEnergie1Stk avgliter elEnergie1 Stk 
| where abw!="" 
| eval abw=if(abw&amp;lt;100, "---", abw)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think this subsearch is too much, so I modify this to turn it over.&lt;BR /&gt;
How about this?&lt;/P&gt;</description>
    <pubDate>Fri, 06 Mar 2020 23:40:28 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-03-06T23:40:28Z</dc:date>
    <item>
      <title>Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488378#M136434</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I'm calculating the average electrical energy consumption per produced piece from today of one of our production machines. &lt;BR /&gt;
Then I want to know the percentage in which this value differs from the average of the last 30 days. &lt;BR /&gt;
The average of the last 30 days is stored in a summary index as one value per day. &lt;/P&gt;

&lt;P&gt;For just this moment, the verified value of the total electrical energy consumption (field "elEnergie1") is 18 kWh. But every new search returns a value which alters between 55 and 65 kWh, sometimes around 22 too. &lt;BR /&gt;
This is the code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=machinedata_w05 source=W05WTSema4IV320732 name=S3.Energiedaten.Wirkenergie_Tag OR name=S7.Prozessdaten.wst_gesamt earliest=@d

| eval {name}=value
| eval day = strftime(_time, "%d.%m.%Y")
| rename S3.Energiedaten.Wirkenergie_Tag as elEnergie1
         S7.Prozessdaten.wst_gesamt as Stk
| table _time elEnergie1 day Stk
| filldown elEnergie1
| autoregress elEnergie1
| table _time elEnergie1 elEnergie1_p1 day Stk
| where elEnergie1!="" OR elEnergie1_p1!="" OR Stk!=""
| eval diff=elEnergie1_p1-elEnergie1
| table _time elEnergie1 elEnergie1_p1 diff day Stk
| where diff&amp;gt;0 OR Stk!=""
| stats first(_time) as _time sum(diff) as elEnergie1 range(Stk) as Stk by day
| where Stk!=0
| eval elEnergie1Stk = round(elEnergie1/Stk, 5),
       elEnergie1=round(elEnergie1, 2)
| table elEnergie1Stk elEnergie1 Stk
| fields - _time
| append
    [
    | search index=machinedata_w05_sum app=Medienverbrauch medium="el.Energie" machine=Sema4 earliest=-30d
    | stats avg(Verbrauch_elEnergie_pro_Stk) as avgliter 
    | fields avgliter
    | eval avgliter=round(avgliter, 5)
    ]
| filldown
| eval abw = round((if(isnull(elEnergie1Stk), -1, elEnergie1Stk)-avgliter)/avgliter*100, 1)
| table abw elEnergie1Stk avgliter elEnergie1 Stk
| where abw!=""
| eval abw=if(abw&amp;lt;100, "---", abw)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After some trial end error I found out that if I just delete the append command, the energy consumption is calculated correctly (the depending calculations are then of course wrong, but that's not the point). &lt;/P&gt;

&lt;P&gt;So my question is: &lt;BR /&gt;
Why does removing/adding the append command changes the value of a previous calculated field?&lt;/P&gt;

&lt;P&gt;I have absolutely no idea what is happening here!?!?&lt;/P&gt;

&lt;P&gt;(If you want to know more about what the whole search does just ask me)&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 15:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488378#M136434</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-06T15:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488379#M136435</link>
      <description>&lt;P&gt;It probably doesn't, not directly.  If you &lt;CODE&gt;inspect&lt;/CODE&gt; your &lt;CODE&gt;job&lt;/CODE&gt; you will probably find that adding the &lt;CODE&gt;append&lt;/CODE&gt; is causing your search to either take &lt;CODE&gt;too much time&lt;/CODE&gt; or use &lt;CODE&gt;too much disk space&lt;/CODE&gt; leaving your job in an incomplete, had-to-abort, &lt;CODE&gt;finalized&lt;/CODE&gt; state, instead of the correct, normal, complete &lt;CODE&gt;Done&lt;/CODE&gt; state.  That is why we stress so hard to avoid &lt;CODE&gt;join&lt;/CODE&gt; and &lt;CODE&gt;append&lt;/CODE&gt;.  It can almost always be done without them (I have only seen 1 case where we could not).&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 15:34:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488379#M136435</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-06T15:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488380#M136436</link>
      <description>&lt;P&gt;Hi woodcock,&lt;/P&gt;

&lt;P&gt;thanks for your reply!&lt;/P&gt;

&lt;P&gt;I don't think this is the issue because the search runs only 0.5 seconds. The search has only 483 events where each event looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"name":"S3.Energiedaten.Wirkenergie_Tag","value":15.000007629394531}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch only has 9 events where each event looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;03/05/2020 23:42:01 +0100, info_min_time=1546297200.000, info_max_time=1583449200.000, info_search_time=1583488430.469, app=Medienverbrauch, area="Wärmetauscherfertigung", medium="el.Energie", machine=Sema4, IV_number=320732, unit_Verbrauch_gesamt=kWh, Verbrauch_elEnergie_pro_Stk="0.06650", Verbrauch_elEnergie_gesamt="52.80", unit_Verbrauch_Stk="kWh/Stk"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I already have a similar search in another dashboard which runs without problems. The only difference is in a few evals and the source.&lt;/P&gt;

&lt;P&gt;But where do I find exactly the job status "finalized" to check if your suggestions is on point?&lt;/P&gt;

&lt;P&gt;The same issue is also with appendcols. &lt;/P&gt;

&lt;P&gt;How can I do it without append? Can you please give me a hint? &lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 15:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488380#M136436</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-06T15:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488381#M136437</link>
      <description>&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/Limitsconf#.5Bsubsearch.5D"&gt;limits.conf&lt;/A&gt;&lt;BR /&gt;
if your append search consume time, the error will cause.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 22:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488381#M136437</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-06T22:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488382#M136438</link>
      <description>&lt;P&gt;If it isn't working after the &lt;CODE&gt;append&lt;/CODE&gt; then it must be corruption of the &lt;CODE&gt;filldown&lt;/CODE&gt;.&lt;BR /&gt;
This is one reason that I NEVER use &lt;CODE&gt;filldown&lt;/CODE&gt; without arguments.&lt;BR /&gt;
In other words, the events returned from the append EITHER:&lt;BR /&gt;
1: have gobs and gobs of fields and rows so the unconstrained &lt;CODE&gt;filldown&lt;/CODE&gt; causes RAM to be exhaused&lt;BR /&gt;
OR&lt;BR /&gt;
2: have fields with values that causes &lt;CODE&gt;abw&lt;/CODE&gt; to get miscalculated.&lt;/P&gt;

&lt;P&gt;It is probably the latter.  You are probably NOT meaning for the appended events to obtain values for &lt;CODE&gt;elEnergie1Stk&lt;/CODE&gt; and &lt;CODE&gt;avgliter&lt;/CODE&gt;, etc.  Fix your &lt;CODE&gt;filldown&lt;/CODE&gt; and/or your math to compensate correctly for the appended events.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 23:10:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488382#M136438</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-06T23:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488383#M136439</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=machinedata_w05_sum app=Medienverbrauch medium="el.Energie" machine=Sema4 earliest=-30d 
    | stats avg(Verbrauch_elEnergie_pro_Stk) as avgliter 
    | fields avgliter 
    | eval avgliter=round(avgliter, 5)
| append [ search index=machinedata_w05 source=W05WTSema4IV320732 name=S3.Energiedaten.Wirkenergie_Tag OR name=S7.Prozessdaten.wst_gesamt earliest=@d 
| eval {name}=value 
| eval day = strftime(_time, "%d.%m.%Y") 
| rename S3.Energiedaten.Wirkenergie_Tag as elEnergie1
    S7.Prozessdaten.wst_gesamt as Stk 
| table _time elEnergie1 day Stk 
| filldown elEnergie1 
| autoregress elEnergie1 
| table _time elEnergie1 elEnergie1_p1 day Stk 
| where elEnergie1!="" OR elEnergie1_p1!="" OR Stk!="" 
| eval diff=elEnergie1_p1-elEnergie1 
| table _time elEnergie1 elEnergie1_p1 diff day Stk 
| where diff&amp;gt;0 OR Stk!="" 
| stats first(_time) as _time sum(diff) as elEnergie1 range(Stk) as Stk by day 
| where Stk!=0 
| eval elEnergie1Stk = round(elEnergie1/Stk, 5),
    elEnergie1=round(elEnergie1, 2) 
| table elEnergie1Stk elEnergie1 Stk 
| fields - _time 
| reverse]
| reverse
| filldown 
| eval abw = round((if(isnull(elEnergie1Stk), -1, elEnergie1Stk)-avgliter)/avgliter*100, 1) 
| table abw elEnergie1Stk avgliter elEnergie1 Stk 
| where abw!="" 
| eval abw=if(abw&amp;lt;100, "---", abw)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think this subsearch is too much, so I modify this to turn it over.&lt;BR /&gt;
How about this?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 23:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488383#M136439</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-06T23:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488384#M136440</link>
      <description>&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;I've got only one event returned from append in a new row.&lt;BR /&gt;
The &lt;CODE&gt;filldown&lt;/CODE&gt; ensures that the returned value is in the same row as the results of the base search. &lt;BR /&gt;
If I use &lt;CODE&gt;appendcols&lt;/CODE&gt;, the &lt;CODE&gt;filldown&lt;/CODE&gt; isn't necessary anymore --&amp;gt; results are still wrong.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;abw&lt;/CODE&gt; is calculated correctly (the value is wrong because &lt;CODE&gt;elEnergie1&lt;/CODE&gt; is wrong but the math is correct). &lt;CODE&gt;avgliter&lt;/CODE&gt; is the correct value (0.05453 in this case). Only &lt;CODE&gt;elEnergie1&lt;/CODE&gt; is way to high. Even &lt;CODE&gt;Stk&lt;/CODE&gt; is right, only &lt;CODE&gt;elEnergie1&lt;/CODE&gt; is wrong.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;You are probably NOT meaning for the&lt;BR /&gt;
appended events to obtain values for&lt;BR /&gt;
elEnergie1Stk and avgliter, etc.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;What does this mean exactly (sorry, not a native speaker)? &lt;BR /&gt;
I only append &lt;STRONG&gt;one&lt;/STRONG&gt; event which is avgliter. &lt;BR /&gt;
I still can't get my head around it why this is behaving like it is.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 07:20:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488384#M136440</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-09T07:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488385#M136441</link>
      <description>&lt;P&gt;Where is this written exactly? I only found that &lt;CODE&gt;append&lt;/CODE&gt; will exceed &lt;CODE&gt;maxout&lt;/CODE&gt; specified for &lt;CODE&gt;subsearch&lt;/CODE&gt; in the &lt;CODE&gt;limits.conf&lt;/CODE&gt;.&lt;BR /&gt;
And the &lt;CODE&gt;subsearch-options&lt;/CODE&gt; are configured as default like written in the docs. Like I said this are only 32 events before the &lt;CODE&gt;stats&lt;/CODE&gt; command and runs in 2.1 seconds. This is way below the limits. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 07:31:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488385#M136441</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-09T07:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488386#M136442</link>
      <description>&lt;P&gt;This works! Thanks a lot!&lt;/P&gt;

&lt;P&gt;I checked the separate searches again. &lt;BR /&gt;
The search in index &lt;CODE&gt;machinedata_w05&lt;/CODE&gt; which searches through appr. 40 Million events per day only runs for 0.2 seconds whereas the search in index &lt;CODE&gt;machinedata_w05_sum&lt;/CODE&gt; which searches through 6000 events per day runs for 2 seconds (both overall events without filters). &lt;BR /&gt;
Can this be the cause?&lt;/P&gt;

&lt;P&gt;I really try to understand it but it's not clear to me yet.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 09:14:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488386#M136442</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-09T09:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding or removing the append command changes a previous calculated field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488387#M136443</link>
      <description>&lt;P&gt;To add to to4kawa's answer an other solution I stumbled upon myself:&lt;/P&gt;

&lt;P&gt;In the job inspector I saw that the &lt;CODE&gt;table&lt;/CODE&gt; command had appr. 1000 inputs and 700000 (?!?!) outputs. &lt;/P&gt;

&lt;P&gt;If I run just the first few lines of the search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=machinedata_w05 source=W05WTSema4IV320732 name=S3.Energiedaten.Wirkenergie_Tag OR name=S7.Prozessdaten.wst_gesamt 

 | eval {name}=value
 | eval day = strftime(_time, "%d.%m.%Y")
 | rename S3.Energiedaten.Wirkenergie_Tag as elEnergie1
          S7.Prozessdaten.wst_gesamt as Stk
 | table _time elEnergie1 day Stk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the table command takes 483 inputs and gives out 250498 outputs. &lt;BR /&gt;
The only other entries with a high event count are &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0,11     dispatch.stream.remote 8   -   134.974
0,05     dispatch.stream.remote.splunk03w05.mycompany.net   4   -   65.486
0,05     dispatch.stream.remote.splunk02w05.mycompany.net   4   -   69.488
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If anybody knows whats going on I would be happy if you let me know it. &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8504i111BB34ECEC489E2/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;When I remove all &lt;CODE&gt;table&lt;/CODE&gt; commands except for the last one in the original search and substitute them with the &lt;CODE&gt;fields&lt;/CODE&gt; command everything works as expected!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 09:43:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-or-removing-the-append-command-changes-a-previous/m-p/488387#M136443</guid>
      <dc:creator>haph</dc:creator>
      <dc:date>2020-03-09T09:43:58Z</dc:date>
    </item>
  </channel>
</rss>

