<?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: What is the eval command doing in this search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248778#M74298</link>
    <description>&lt;P&gt;That's because in the first case, there's an &lt;CODE&gt;eval()&lt;/CODE&gt; function to evaluate the &lt;CODE&gt;if()&lt;/CODE&gt; expression, while in the second case there isn't.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval(if(method="GET", 0, 1))&lt;/CODE&gt; evaluates to 0 if the method is GET, to 1 otherwise.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2016 19:24:05 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2016-11-28T19:24:05Z</dc:date>
    <item>
      <title>What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248769#M74289</link>
      <description>&lt;P&gt;We use eval command to create new field, and we used this as function ex: &lt;CODE&gt;|stats count(eval(method="GET")) as get&lt;/CODE&gt;. Can someone explain this example clearly? What is &lt;CODE&gt;eval&lt;/CODE&gt; doing here?&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 09:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248769#M74289</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2016-11-27T09:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248770#M74290</link>
      <description>&lt;P&gt;&lt;CODE&gt;count(eval())&lt;/CODE&gt; is testing the boolean expression inside the &lt;CODE&gt;eval()&lt;/CODE&gt; and only counting those events that yield true, ie those with &lt;CODE&gt;method="GET"&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 10:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248770#M74290</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-11-27T10:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248771#M74291</link>
      <description>&lt;P&gt;The manual explains it at &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/Search/Usestatswithevalexpressionsandfunctions"&gt;Use stats with eval expressions and functions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;One example there is - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status=404 | stats dc(eval(if(status=404, ip, NULL))) AS dc_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;your &lt;CODE&gt;method="GET"&lt;/CODE&gt; is a shortcut for the &lt;CODE&gt;if(method="GET",1,0)&lt;/CODE&gt; command. &lt;/P&gt;</description>
      <pubDate>Sun, 27 Nov 2016 23:01:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248771#M74291</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2016-11-27T23:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248772#M74292</link>
      <description>&lt;P&gt;|eval newitem=if(status=404, ip, null) &lt;BR /&gt;
it returns "ip"&lt;BR /&gt;
then we can use | stats dc(newItem).&lt;/P&gt;

&lt;P&gt;what does eval do after returning an argument (ip). like |stats dc(eval(ip))&lt;/P&gt;

&lt;P&gt;meaning of eval(ip) ?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248772#M74292</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2016-11-28T18:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248773#M74293</link>
      <description>&lt;P&gt;&lt;CODE&gt;| stats dc(eval(ip))&lt;/CODE&gt; is the same as &lt;CODE&gt;| stats dc(ip)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248773#M74293</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-11-28T18:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248774#M74294</link>
      <description>&lt;P&gt;what does eval(ip) return?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:29:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248774#M74294</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2016-11-28T18:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248775#M74295</link>
      <description>&lt;P&gt;&lt;CODE&gt;eval(ip)&lt;/CODE&gt; evaluates the expression &lt;CODE&gt;ip&lt;/CODE&gt;, so it returns &lt;CODE&gt;ip&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 18:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248775#M74295</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-11-28T18:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248776#M74296</link>
      <description>&lt;P&gt;as you said "| stats dc(eval(ip)) is the same as | stats dc(ip)"&lt;/P&gt;

&lt;P&gt;if(method="GET", 0 ,1) return  0 or 1&lt;/P&gt;

&lt;P&gt;then dc(eval(0)) should be same as dc (0)&lt;/P&gt;

&lt;P&gt;sourcetype=access_combined* |stats dc(eval(if(method="GET", 0 ,1))) as dc_method &lt;/P&gt;

&lt;P&gt;should be same as   sourcetype=access_combined* |stats dc(if(method="GET", 0 ,1)) as  dc_method&lt;/P&gt;

&lt;P&gt;but not showing 0 results (last one)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:56:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248776#M74296</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2020-09-29T11:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248777#M74297</link>
      <description>&lt;P&gt;as you said "| stats dc(eval(ip)) is the same as | stats dc(ip)"&lt;/P&gt;

&lt;P&gt;if(method="GET", 0 ,1) return 0 or 1&lt;/P&gt;

&lt;P&gt;then dc(eval(0)) should be same as dc (0)&lt;/P&gt;

&lt;P&gt;sourcetype=access_combined* |stats dc(eval(if(method="GET", 0 ,1))) as dc_method&lt;/P&gt;

&lt;P&gt;giving 2 as count&lt;/P&gt;

&lt;P&gt;should be same as sourcetype=access_combined* |stats dc(if(method="GET", 0 ,1)) as dc_method&lt;/P&gt;

&lt;P&gt;0 as count&lt;BR /&gt;
but showing 0 results (last one)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248777#M74297</guid>
      <dc:creator>nagarjuna280</dc:creator>
      <dc:date>2020-09-29T11:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: What is the eval command doing in this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248778#M74298</link>
      <description>&lt;P&gt;That's because in the first case, there's an &lt;CODE&gt;eval()&lt;/CODE&gt; function to evaluate the &lt;CODE&gt;if()&lt;/CODE&gt; expression, while in the second case there isn't.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval(if(method="GET", 0, 1))&lt;/CODE&gt; evaluates to 0 if the method is GET, to 1 otherwise.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 19:24:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-eval-command-doing-in-this-search/m-p/248778#M74298</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-11-28T19:24:05Z</dc:date>
    </item>
  </channel>
</rss>

