<?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 Issue in returning space from eval macro in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165870#M47169</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am in need of an eval macro that takes in three values, examines them and returns the values for three separate fields. I need to return all the three values at once. My macro definition looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_macro(3)]
args = val1,val2,val3
definition = case("$val1$"!="*" AND "$val2$"!="*" AND $val3$=="*","Field1=\"$val1$\" Field2=\"$val2$\" Field3=\"*\"", "$val1$"!="*" AND "$val2$"=="*" AND $val3$!="*","$Field1$=\"$val1$\" Field2=\"*\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"!="*" AND $val3$!="*","$Field1$=\"*\" Field2=\"$val2$\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"=="*" AND $val3$!="*","$Field1$=\"-\" Field2=\"-\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"!="*" AND $val3$=="*","$Field1$=\"-\" Field2=\"$val2$\" Field3=\"-\"", "$val1$"!="*" AND "$val2$"=="*" AND $val3$=="*","$Field1$=\"$val1$\" Field2=\"-\" Field3=\"-\"", "$val1$"=="*" AND "$val2$"=="*" AND $val3$=="*","$Field1$=\"-\" Field2=\"-\" Field3=\"-\"", "$val1$"!="*" AND "$val2$"!="*" AND $val3$!="*","$Field1$=\"$val1$\" Field2=\"$val2$\" Field3=\"$val3$\"")
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I use this macro in any of my search queries I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;The definition of macro 'my_macro(3)' is expected to be an eval expression that returns a string.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The values val1, val2 and val3 are obtained from dropdowns in the view&lt;/P&gt;

&lt;P&gt;Below is my search query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex earliest=&amp;lt;time&amp;gt; latest=&amp;lt;time&amp;gt; `my_macro($val1$,$val2$,$val3$)` | bucket _time span=span | stats ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know where I am going wrong and how I can achieve this.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Keerthana&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2014 07:30:00 GMT</pubDate>
    <dc:creator>keerthana_k</dc:creator>
    <dc:date>2014-02-26T07:30:00Z</dc:date>
    <item>
      <title>Issue in returning space from eval macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165870#M47169</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am in need of an eval macro that takes in three values, examines them and returns the values for three separate fields. I need to return all the three values at once. My macro definition looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_macro(3)]
args = val1,val2,val3
definition = case("$val1$"!="*" AND "$val2$"!="*" AND $val3$=="*","Field1=\"$val1$\" Field2=\"$val2$\" Field3=\"*\"", "$val1$"!="*" AND "$val2$"=="*" AND $val3$!="*","$Field1$=\"$val1$\" Field2=\"*\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"!="*" AND $val3$!="*","$Field1$=\"*\" Field2=\"$val2$\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"=="*" AND $val3$!="*","$Field1$=\"-\" Field2=\"-\" Field3=\"$val3$\"", "$val1$"=="*" AND "$val2$"!="*" AND $val3$=="*","$Field1$=\"-\" Field2=\"$val2$\" Field3=\"-\"", "$val1$"!="*" AND "$val2$"=="*" AND $val3$=="*","$Field1$=\"$val1$\" Field2=\"-\" Field3=\"-\"", "$val1$"=="*" AND "$val2$"=="*" AND $val3$=="*","$Field1$=\"-\" Field2=\"-\" Field3=\"-\"", "$val1$"!="*" AND "$val2$"!="*" AND $val3$!="*","$Field1$=\"$val1$\" Field2=\"$val2$\" Field3=\"$val3$\"")
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I use this macro in any of my search queries I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;The definition of macro 'my_macro(3)' is expected to be an eval expression that returns a string.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The values val1, val2 and val3 are obtained from dropdowns in the view&lt;/P&gt;

&lt;P&gt;Below is my search query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex earliest=&amp;lt;time&amp;gt; latest=&amp;lt;time&amp;gt; `my_macro($val1$,$val2$,$val3$)` | bucket _time span=span | stats ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know where I am going wrong and how I can achieve this.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Keerthana&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2014 07:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165870#M47169</guid>
      <dc:creator>keerthana_k</dc:creator>
      <dc:date>2014-02-26T07:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in returning space from eval macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165871#M47170</link>
      <description>&lt;P&gt;What is the search command are you performing could you post that too?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2014 08:56:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165871#M47170</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-02-26T08:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in returning space from eval macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165872#M47171</link>
      <description>&lt;P&gt;I have edited the question to include the search too.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2014 09:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165872#M47171</guid>
      <dc:creator>keerthana_k</dc:creator>
      <dc:date>2014-02-26T09:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in returning space from eval macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165873#M47172</link>
      <description>&lt;P&gt;Hello Keerthana,&lt;BR /&gt;
It's not the macro it's your search which is failing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex earliest=&amp;lt;time&amp;gt; latest=&amp;lt;time&amp;gt; |eval a=`my_macro($val1$,$val2$,$val3$)` | bucket _time span=span | stats ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if it gives you some error see the inspect link and figure out the error in the replaced search command.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2014 10:06:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Issue-in-returning-space-from-eval-macro/m-p/165873#M47172</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2014-02-26T10:06:27Z</dc:date>
    </item>
  </channel>
</rss>

