<?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 Help on eval in a stats command in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603231#M12990</link>
    <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;I triy to add a condition in my eval command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats  sum(eval(retrans_bytes)) as retrans by site
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;So I need to do something like this but it doesnt works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats  sum(eval(retrans_bytes) AND (process="view.exe" OR netproc_process="remotemks.exe")) as retrans by site
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;could you help please?&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 14:55:08 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2022-06-27T14:55:08Z</dc:date>
    <item>
      <title>Help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603231#M12990</link>
      <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;I triy to add a condition in my eval command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats  sum(eval(retrans_bytes)) as retrans by site
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;So I need to do something like this but it doesnt works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats  sum(eval(retrans_bytes) AND (process="view.exe" OR netproc_process="remotemks.exe")) as retrans by site
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;could you help please?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 14:55:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603231#M12990</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-06-27T14:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603232#M12991</link>
      <description>&lt;P&gt;this must work for you :&lt;BR /&gt;|your code ...&lt;BR /&gt;|search&amp;nbsp;process="view.exe" OR netproc_process="remotemks.exe"&lt;BR /&gt;| stats sum(retrans_bytes)&amp;nbsp; as retrans&amp;nbsp; by site&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 04:55:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603232#M12991</guid>
      <dc:creator>marysan</dc:creator>
      <dc:date>2022-06-25T04:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603234#M12992</link>
      <description>&lt;P&gt;I know but it's not my needs because I must use 2 different condition in my stats command from the same field&lt;/P&gt;&lt;P&gt;something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(eval(retrans_bytes) AND (process="view.exe" OR netproc_process="remotemks.exe")) as retrans, sum(eval(retrans_bytes) AND (process=*)) as retrans2 by site&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 06:23:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603234#M12992</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-06-25T06:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603236#M12993</link>
      <description>&lt;P&gt;dear friend your query doesn't show different conditions :&lt;BR /&gt;one hand: (process="view.exe" OR netproc_process="remotemks.exe") and the other hand (process=*) !!&lt;BR /&gt;first condition is a subset of second condition&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;but I suppose that this must work for your target:&lt;BR /&gt;|&amp;nbsp;eval&amp;nbsp;flag=if(process="view.exe"&amp;nbsp;OR netproc_process="remotemks.exe",1,0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;|&amp;nbsp;stats&amp;nbsp;sum(returnts_bytes) as returns_bytes by site,flag&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 06:38:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603236#M12993</guid>
      <dc:creator>marysan</dc:creator>
      <dc:date>2022-06-25T06:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603237#M12994</link>
      <description>&lt;P&gt;Pearhaps i explain badly&lt;/P&gt;&lt;P&gt;But what I need is to stats sum separatively&amp;nbsp;&lt;SPAN&gt;process="view.exe" OR netproc_process="remotemks.exe") and netproc-process=* because I need to calculate à ratio between these&amp;nbsp;2 fields&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So&amp;nbsp;first condition is not a subset of second condition!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So i need to build 2 différents stats sum(eval....) with these 2 différents conditions....&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 07:10:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603237#M12994</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-06-25T07:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603248#M12997</link>
      <description>&lt;P&gt;The eval stats operation is somewhat incompletely and confusingly described in docs (I have to submit a feedback if I remember it when I get home).&lt;/P&gt;&lt;P&gt;A simple (or complex) condition is silently cast to 0/1 as true/false. That means that for a count() aggregation it works pretty well. But for other functions you have to manually specify a value which will be aggregated.&lt;/P&gt;&lt;P&gt;You might think of&lt;/P&gt;&lt;PRE&gt;stats agg(eval(expression))&lt;/PRE&gt;&lt;P&gt;as&lt;/P&gt;&lt;PRE&gt;eval var=expression | stats agg(var)&lt;/PRE&gt;&lt;P&gt;So what you need is (if I understand the logic of your condition)&lt;/P&gt;&lt;PRE&gt;stats sum(if(process="view.exe" OR netproc_process="remotemks.exe",retrans_bytes,null())) as [...]&lt;/PRE&gt;&lt;P&gt;In your particular case you can use 0 instead of null() because it doesn't skew the results but for other aggregations null() is better because splunk doesn't aggregate null fields so they are filtered out.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 09:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603248#M12997</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-25T09:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603252#M12998</link>
      <description>&lt;P&gt;So considering my need, is it ok to do this :&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;stats sum(if(process="view.exe" OR netproc_process="remotemks.exe",retrans_bytes,null())) as retrans1,&amp;nbsp;sum(if(process=*, retrans_bytes,null())) as retrans2&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 09:29:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603252#M12998</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-06-25T09:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603254#M12999</link>
      <description>&lt;P&gt;Close but not quite. I didn't count the parentheses&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But more importantly, the comparison in if is not a search operator but a simple equality comparison.&amp;nbsp; So you can't do&lt;/P&gt;&lt;PRE&gt;if(index=*,...)&lt;/PRE&gt;&lt;P&gt;If I remember correctly, there is another function for that - check match() or searchmatch()&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 09:35:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603254#M12999</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-25T09:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603268#M13000</link>
      <description>&lt;P&gt;sorry but i am unable to apply it and not sure that my need is well understanded&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`index` (sourcetype="netproc" netproc_process="vmware-view.exe" OR netproc_process="vmware.remotemks.exe") 
| fields netproc_tcp_retrans_bytes site 
| stats sum(netproc_tcp_retrans_bytes) as retrans by site&lt;/LI-CODE&gt;&lt;P&gt;Actually I sum the field&amp;nbsp; "netproc_tcp_retrans_bytes" like this&lt;/P&gt;&lt;P&gt;what I need is to use the netproc_process field not in the sourcetype but only in the stats command&lt;/P&gt;&lt;P&gt;so I need something like this but I dont succeed to write this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`index` (sourcetype="netproc_tcp" netproc_process="vmware-view.exe" OR netproc_process="vmware.remotemks.exe") 
| fields netproc_tcp_retrans_bytes site 
| stats sum(eval(netproc_tcp_retrans_bytes AND netproc_process="vmware-view.exe" OR netproc_process="vmware.remotemks.exe")) as retrans by site&lt;/LI-CODE&gt;&lt;P&gt;So is anybody can help me please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 17:02:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603268#M13000</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2022-06-25T17:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: help on eval in a stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603285#M13002</link>
      <description>&lt;P&gt;You're most probably not understood correctly. You keep repeating "I'm trying to do 'this' but 'this' is written wrongly".&lt;/P&gt;&lt;P&gt;How are we supposed to know what you're trying to achieve then?&lt;/P&gt;&lt;P&gt;Try to rephrase it and tell us what is the problem you're trying to solve without using SPL.&lt;/P&gt;&lt;P&gt;Alternatively, use the other approach I showed you before - don't do stats(eval) because it does get confusing at times, but try to eval an additional field(s) first and then aggregate simply on this field (or fields).&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 05:45:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-on-eval-in-a-stats-command/m-p/603285#M13002</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-26T05:45:11Z</dc:date>
    </item>
  </channel>
</rss>

