<?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: using EVAL in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25593#M4853</link>
    <description>&lt;P&gt;Thanks. &lt;BR /&gt;
Can you tell me if, rather they trying to evaluate the formula within the search string, I can insert some code into the form... so that when the user enters 0191, the form calls a script to apply the formula and then inserts he result to the search?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2012 14:20:39 GMT</pubDate>
    <dc:creator>mikefoti</dc:creator>
    <dc:date>2012-04-12T14:20:39Z</dc:date>
    <item>
      <title>using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25589#M4849</link>
      <description>&lt;P&gt;I have a form that prompts user for a 4 digit number representing a location. I want to insert that location number into a formula that calculates the location's IP address. I then want to use that IP as the basis for a search. &lt;/P&gt;

&lt;P&gt;My formula with a location number of 0191 looks like this: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;10.(INT(0191/256+170)).(MOD(0191,256)).48)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;The resulting IP address is 10.170.191.48&lt;/P&gt;

&lt;P&gt;I then hope to use the IP is the following search:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index="winradius" nps_nasIP=10.170.191.48&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;So I think I would use EVAL as follows:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index="winradius" (eval nps_nasIP=10.(INT(0191/256+170)).(MOD(0191,256)).48)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But this doesn't work. &lt;BR /&gt;
No error message... just no results are returned. &lt;BR /&gt;
Not sure how to fix or even troubleshoot this.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 13:26:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25589#M4849</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T13:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25590#M4850</link>
      <description>&lt;P&gt;You could do this using a subsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="winradius" [ | stats count | eval nps_nasIP="10." . tostring(floor(tonumber("0191")/256+170)) . "." . tostring(tonumber("0191")%256) . ".48" | return nps_nasIP ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2012 13:42:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25590#M4850</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-12T13:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25591#M4851</link>
      <description>&lt;P&gt;A couple of things....&lt;BR /&gt;
1 - thanks for the very quick reply!&lt;BR /&gt;
2 - unfortunately it doesn't work&lt;BR /&gt;
3 - what does this string do . "." . &lt;BR /&gt;
4 - in my formula INT and MOD are mathematical functions so  I would not expect replacing the function names with "tonumber" to return the expected result&lt;/P&gt;

&lt;P&gt;INT means "round the result to nearest whole number"&lt;BR /&gt;
MOD(191/256) means "tell me the remainder if 191 is devided by 265"&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 13:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25591#M4851</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T13:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25592#M4852</link>
      <description>&lt;P&gt;it should work, at least on 4.3. The subsearch creates an additional condition for the outer search &lt;CODE&gt;nps_nasIP="10.170.191.48"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The dot characeter &lt;CODE&gt;.&lt;/CODE&gt; is used for string concatenation. &lt;/P&gt;

&lt;P&gt;There's no INT and MOD function for Splunk's eval command so I changed them to &lt;CODE&gt;INT ==&amp;gt; floor(tonumber(X))&lt;/CODE&gt; and &lt;CODE&gt;MOD ==&amp;gt; X%Y&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Here's a list of functions you can use with the eval command: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 13:57:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25592#M4852</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-12T13:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25593#M4853</link>
      <description>&lt;P&gt;Thanks. &lt;BR /&gt;
Can you tell me if, rather they trying to evaluate the formula within the search string, I can insert some code into the form... so that when the user enters 0191, the form calls a script to apply the formula and then inserts he result to the search?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 14:20:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25593#M4853</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-12T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25594#M4854</link>
      <description>&lt;P&gt;Yes, it's possible. You should take a look at the SideviewUtils app and try to do that using customBahavior on form elements.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/apps/36405/sideview-utils"&gt;http://splunk-base.splunk.com/apps/36405/sideview-utils&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2012 14:23:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25594#M4854</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-12T14:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: using EVAL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25595#M4855</link>
      <description>&lt;P&gt;or just round(x)&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2014 17:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-EVAL/m-p/25595#M4855</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2014-11-21T17:59:14Z</dc:date>
    </item>
  </channel>
</rss>

