<?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: Passing eval value to script in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145256#M40466</link>
    <description>&lt;P&gt;If you do &lt;CODE&gt;return param&lt;/CODE&gt; you'll get &lt;CODE&gt;param=value&lt;/CODE&gt;, if you do &lt;CODE&gt;return $param&lt;/CODE&gt; you'll get just &lt;CODE&gt;value&lt;/CODE&gt; without &lt;CODE&gt;param=&lt;/CODE&gt; - the latter looked like the one you asked for in the question.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/return"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/return&lt;/A&gt; see example 3&lt;/P&gt;</description>
    <pubDate>Tue, 29 Apr 2014 00:13:53 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-04-29T00:13:53Z</dc:date>
    <item>
      <title>Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145251#M40461</link>
      <description>&lt;P&gt;Hi friends&lt;/P&gt;

&lt;P&gt;I have been working for hours, but it has been impossible. It seems too easy, but i don´t manage to resolve it. Please help. &lt;/P&gt;

&lt;P&gt;I have a dashboard with sideview utils, with two editable textfields and a button. When the user press the button, i have to multiply the numeric value of the textfield, and pass it to an external python script&lt;/P&gt;

&lt;P&gt;For example, this works:&lt;/P&gt;

&lt;P&gt;| script python changevalue.py "quality:$warning$:$critical$" (warning and critical are the textfield names.&lt;/P&gt;

&lt;P&gt;But when i try to do somethins as simple as:&lt;/P&gt;

&lt;P&gt;| eval umbral1 = $warning$ * 1024 * 300&lt;BR /&gt;
| eval umbral2 = $critical$ * 1024 * 300&lt;BR /&gt;
| script python changevalue.py "quality:$umbral1$:$umbral2$"&lt;/P&gt;

&lt;P&gt;It fails. umbral1 and umbral2 is in blank, and i can't use this variables. &lt;/P&gt;

&lt;P&gt;It must be very simple to resolve, but i must be blind.  Please help&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 20:59:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145251#M40461</guid>
      <dc:creator>albertohontoria</dc:creator>
      <dc:date>2014-04-28T20:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145252#M40462</link>
      <description>&lt;P&gt;How about this&lt;BR /&gt;
| script python changevalue.py "quality:"+umbral1+":"+umbral2&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 21:09:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145252#M40462</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-28T21:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145253#M40463</link>
      <description>&lt;P&gt;I have already tried it, without sucess. The result is this&lt;/P&gt;

&lt;P&gt;| eval umbral1 = 200 * 1024 * 300 | eval umbral2 = 300 * 1024 * 300 | script python hello "quality:"+umbral1+":"+umbral2&lt;/P&gt;

&lt;P&gt;It doesn´t seem to preprocess variables passed to the script. With components like textfields and pulldowns using $variable$ it works, but using eval variables it doesn't work.&lt;/P&gt;

&lt;P&gt;I am a bit lost about this&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 21:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145253#M40463</guid>
      <dc:creator>albertohontoria</dc:creator>
      <dc:date>2014-04-28T21:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145254#M40464</link>
      <description>&lt;P&gt;You can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| script python changevalue.py [stats count | eval umbral1 = $warning$ * 1024 * 300 | eval umbral2 = $critical$ * 1024 * 300 | eval param = "quality:".umbral1.":".umbral2" | return $param]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch creates a dummy event, performs your calculations, and returns a parameter string to be used by your command.&lt;BR /&gt;
Note, if run from within a dashboard you may need to escape the dollar sign with dollar signs similar to as you would escape a backslash with another backslash.&lt;/P&gt;

&lt;P&gt;As an alternative, this may work in some way as well:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval umbral1 = $warning$ * 1024 * 300 | eval umbral2 = $critical$ * 1024 * 300 | script python changevalue.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;According to the docs &lt;CODE&gt;script&lt;/CODE&gt; passes the top 100 results to the script, so you should somehow be able to get that dummy event from the script.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145254#M40464</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-28T22:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145255#M40465</link>
      <description>&lt;P&gt;Thanks a lot. The returning value is in the format "param=quality:...", but i have managed to trim the string and pass it to the script. &lt;/P&gt;

&lt;P&gt;By the way, this function doesn't work. &lt;BR /&gt;
eval param = "quality:".umbral1.":".umbral2" | return $param&lt;/P&gt;

&lt;P&gt;The correct way is this one:&lt;BR /&gt;
eval param = "$vlan$:traffic:"+umbral1+":"+umbral2 | return param&lt;/P&gt;

&lt;P&gt;Thanks again. You have my points&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 00:00:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145255#M40465</guid>
      <dc:creator>albertohontoria</dc:creator>
      <dc:date>2014-04-29T00:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Passing eval value to script</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145256#M40466</link>
      <description>&lt;P&gt;If you do &lt;CODE&gt;return param&lt;/CODE&gt; you'll get &lt;CODE&gt;param=value&lt;/CODE&gt;, if you do &lt;CODE&gt;return $param&lt;/CODE&gt; you'll get just &lt;CODE&gt;value&lt;/CODE&gt; without &lt;CODE&gt;param=&lt;/CODE&gt; - the latter looked like the one you asked for in the question.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/return"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.3/SearchReference/return&lt;/A&gt; see example 3&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 00:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-eval-value-to-script/m-p/145256#M40466</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-29T00:13:53Z</dc:date>
    </item>
  </channel>
</rss>

