<?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: Require working example of iseval=true in Splunk macro definition in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229877#M2001</link>
    <description>&lt;P&gt;I am very much struggling to understand what you mean.  I am at a total loss.  Start over, and describe your EXACT problem (forget about any part of the solution).  What &lt;EM&gt;exactly&lt;/EM&gt; are you trying to do?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2017 20:00:40 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-02-07T20:00:40Z</dc:date>
    <item>
      <title>Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229872#M1996</link>
      <description>&lt;P&gt;Please provide working example of iseval=true or iseval=1 as that also did not work as described in Splunk docs (&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Macrosconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Admin/Macrosconf&lt;/A&gt;) or in macros.conf. Here is what I tries for iseval=true. I just removed eval $bytes$= from definition which was working fine for me without iseval.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#Macro with one argument. iseval true and no Validation or Error Message
[format_bytes_eval_true(1)]
args = bytes
definition = case($bytes$&amp;gt;=1125899906842624 AND $bytes$&amp;gt;1152921504606846976, tostring(round($bytes$/1152921504606846976,2))+" ZB",$bytes$&amp;gt;=1099511627776 AND committed&amp;lt;1125899906842624,tostring(round($bytes$/1073741824,2))+" TB",$bytes$&amp;gt;=1073741824 AND $bytes$&amp;lt;1099511627776, tostring(round($bytes$/1073741824,2))+" GB", $bytes$&amp;gt;=1048576 AND $bytes$&amp;lt;1073741824, tostring(round($bytes$/1048576,2))+" MB", $bytes$&amp;gt;1024 AND $bytes$&amp;lt;1073741824, tostring(round($bytes$/1024,2))+" KB", $bytes$&amp;lt;1024,tostring($bytes$+" Bytes"),1=1,tostring(round($bytes$/1152921504606846976,2))+" ZB")
errormsg =
iseval = true
validation =
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I tried on Splunk Enterprise 6.5&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2017 19:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229872#M1996</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-15T19:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229873#M1997</link>
      <description>&lt;P&gt;If really it is about an example for which &lt;CODE&gt;iseval=1&lt;/CODE&gt; works, here is one with arguments as constants. Might not work with &lt;CODE&gt;field names&lt;/CODE&gt; as parameters though:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;$SPLUNK_HOME$\etc\users\admin\search\local\macros.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ab(2)]
args = p,q
definition = case($p$ &amp;gt; $q$, tostring($p$), $q$ &amp;gt; $p$, tostring($q$), 1=1, tostring($p$))
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And here is the output&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2315i6C6908B21E6C4566/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;For macro with &lt;CODE&gt;iseval=0&lt;/CODE&gt;, it should look something like:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[isevalzero(2)]
args = p,q
definition = eval first=$p$*100 | eval second=$q$*100
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2316iD666EBBE51657BDC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2017 21:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229873#M1997</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2017-01-15T21:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229874#M1998</link>
      <description>&lt;P&gt;@gokadroid&lt;/P&gt;

&lt;P&gt;The example in my question works without iseval=true or iseval=1 with the definition like the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;definition = eval $byte$ = case (....)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The intent of my question was to check as to what am I doing wrong when I try to check iseval from macro definition and change the definition to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;definition = case (...)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As stated in the question, I have already tried iseval=true and iseval=1 but none of them work. By the way I want to pass field name as an argument not value.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2017 05:25:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229874#M1998</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-17T05:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229875#M1999</link>
      <description>&lt;P&gt;Here is one that worked for me to remove leading '1' from telephone numbers:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[normalize_mdn(1)]
args = mdn
iseval = true
definition = replace("$mdn$","1?(.*)","1\1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And don't forget about &lt;CODE&gt;$SPLUNK_HOME/etc/system/README/&lt;/CODE&gt; which is Splunk's home for working examples of every configuration file.  In there I found &lt;CODE&gt;macros.conf.example&lt;/CODE&gt; with this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# example of an eval-based definition.  For example in this case
# `fooeval(10,20)` would get replaced by 10 + 20
[fooeval(2)]
args = foo, bar
definition = if (bar &amp;gt; 0, "$foo$ + $bar$", "$foo$ - $bar$")
iseval = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2017 14:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229875#M1999</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-01-17T14:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229876#M2000</link>
      <description>&lt;P&gt;@woodcock, thanks for your reply. In the example that I have used input argument has been used as conditional statement in case. Can you point out issue with the same? &lt;/P&gt;

&lt;P&gt;The same condition works without iseval with slightly different definition i.e.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;definition = eval $byte$ = case (....)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2017 16:50:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229876#M2000</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-17T16:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Require working example of iseval=true in Splunk macro definition</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229877#M2001</link>
      <description>&lt;P&gt;I am very much struggling to understand what you mean.  I am at a total loss.  Start over, and describe your EXACT problem (forget about any part of the solution).  What &lt;EM&gt;exactly&lt;/EM&gt; are you trying to do?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 20:00:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Require-working-example-of-iseval-true-in-Splunk-macro/m-p/229877#M2001</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-07T20:00:40Z</dc:date>
    </item>
  </channel>
</rss>

