<?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 do I have to use eval for this search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506571#M141718</link>
    <description>&lt;LI-CODE lang="markup"&gt;| stats count(eval(status=200))&lt;/LI-CODE&gt;&lt;P&gt;does &lt;STRONG&gt;NOT&lt;/STRONG&gt; create a new field nor does it assign a value to a field.&amp;nbsp; It merely examines the existing 'status' field in the event and returns 1 (&lt;FONT face="courier new,courier"&gt;true)&lt;/FONT&gt; if that value is 200 or 0 (zero) (&lt;FONT face="courier new,courier"&gt;false)&lt;/FONT&gt; if it is something else.&amp;nbsp; The count function then tabulates the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; results.&lt;/P&gt;&lt;P&gt;Note: &lt;FONT face="courier new,courier"&gt;stats count(eval(status=200))&lt;/FONT&gt; may yield unexpected results when status&amp;lt;&amp;gt;200.&amp;nbsp; Compare it to &lt;FONT face="courier new,courier"&gt;stats sum(eval(status=200))&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jun 2020 18:18:33 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-06-29T18:18:33Z</dc:date>
    <item>
      <title>Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506563#M141715</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does this search return nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count(status=200) AS Success&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While this search returns what I expect?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count(eval(status=200)) AS success&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506563#M141715</guid>
      <dc:creator>adamfrisbee</dc:creator>
      <dc:date>2020-06-29T17:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506568#M141716</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; function says the argument to &lt;FONT face="courier new,courier"&gt;count&lt;/FONT&gt; is an expression rather than a field.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:58:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506568#M141716</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-29T17:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506569#M141717</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/176432"&gt;@adamfrisbee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first SPL there is no field named "status=200". So it fails.&lt;/P&gt;&lt;PRE&gt;| stats count(status=200) AS Success&lt;/PRE&gt;&lt;P&gt;The second one has eval nested in, which is equivalent to create a new filed with status=200. So now the stats count the new field.&lt;/P&gt;&lt;PRE&gt;| stats count(eval(status=200)) AS success&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506569#M141717</guid>
      <dc:creator>anilchaithu</dc:creator>
      <dc:date>2020-06-29T18:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506571#M141718</link>
      <description>&lt;LI-CODE lang="markup"&gt;| stats count(eval(status=200))&lt;/LI-CODE&gt;&lt;P&gt;does &lt;STRONG&gt;NOT&lt;/STRONG&gt; create a new field nor does it assign a value to a field.&amp;nbsp; It merely examines the existing 'status' field in the event and returns 1 (&lt;FONT face="courier new,courier"&gt;true)&lt;/FONT&gt; if that value is 200 or 0 (zero) (&lt;FONT face="courier new,courier"&gt;false)&lt;/FONT&gt; if it is something else.&amp;nbsp; The count function then tabulates the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; results.&lt;/P&gt;&lt;P&gt;Note: &lt;FONT face="courier new,courier"&gt;stats count(eval(status=200))&lt;/FONT&gt; may yield unexpected results when status&amp;lt;&amp;gt;200.&amp;nbsp; Compare it to &lt;FONT face="courier new,courier"&gt;stats sum(eval(status=200))&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506571#M141718</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-29T18:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506586#M141723</link>
      <description>&lt;P&gt;I thought `eval` always created a new field?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does it not in this case?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 19:47:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506586#M141723</guid>
      <dc:creator>adamfrisbee</dc:creator>
      <dc:date>2020-06-29T19:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I have to use eval for this search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506589#M141724</link>
      <description>&lt;P&gt;I guess you could say &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; works differently within the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command.&amp;nbsp; Run this query to see for yourself.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval status=404 
| stats count(eval(status=200)) as count, values(status) as status 
| table count status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You should get "0&amp;nbsp; 404" as the result, showing the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; function had no effect on the status field.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 20:04:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-I-have-to-use-eval-for-this-search/m-p/506589#M141724</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-29T20:04:16Z</dc:date>
    </item>
  </channel>
</rss>

