<?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 Calling an eval-macro in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477434#M133988</link>
    <description>&lt;P&gt;Hi All, I can't put an eval before my search syntax so I am trying to use an eval-Macro called "FriendlyEval"&lt;BR /&gt;
However, I can't seem to find a way to call it! &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The macro&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;| eval Friendly=$Friend$ &lt;BR /&gt;
| lookup Friendly_Name.csv Friendly OUTPUT FullHost&lt;BR /&gt;
| lookup Friendly_Name.csv Friendly OUTPUT FullHostHSB&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The Search&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;eventtype=eop_WinEventLog:Application&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;FriendlyEval&lt;/CODE&gt; &lt;STRONG&gt;&lt;EM&gt;- where I need to call the macro&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;host IN (FullHost, FullHostHSB) Message="&lt;EM&gt;OMIS $omis01$&lt;/EM&gt;" OR TaskCategory="omis $omis01$" &lt;BR /&gt;
Type IN ($Type01$)&lt;/P&gt;

&lt;P&gt;| table _time host TaskCategory Type EventCode Message&lt;BR /&gt;
| sort - _time&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 04:18:38 GMT</pubDate>
    <dc:creator>ignacm01</dc:creator>
    <dc:date>2020-09-30T04:18:38Z</dc:date>
    <item>
      <title>Calling an eval-macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477434#M133988</link>
      <description>&lt;P&gt;Hi All, I can't put an eval before my search syntax so I am trying to use an eval-Macro called "FriendlyEval"&lt;BR /&gt;
However, I can't seem to find a way to call it! &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The macro&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;| eval Friendly=$Friend$ &lt;BR /&gt;
| lookup Friendly_Name.csv Friendly OUTPUT FullHost&lt;BR /&gt;
| lookup Friendly_Name.csv Friendly OUTPUT FullHostHSB&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;The Search&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;eventtype=eop_WinEventLog:Application&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;FriendlyEval&lt;/CODE&gt; &lt;STRONG&gt;&lt;EM&gt;- where I need to call the macro&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;host IN (FullHost, FullHostHSB) Message="&lt;EM&gt;OMIS $omis01$&lt;/EM&gt;" OR TaskCategory="omis $omis01$" &lt;BR /&gt;
Type IN ($Type01$)&lt;/P&gt;

&lt;P&gt;| table _time host TaskCategory Type EventCode Message&lt;BR /&gt;
| sort - _time&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:18:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477434#M133988</guid>
      <dc:creator>ignacm01</dc:creator>
      <dc:date>2020-09-30T04:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an eval-macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477435#M133989</link>
      <description>&lt;P&gt;When using a macro, the expanded macro definition has to make sense (like you had written the query using the definition instead of the macro).  In your example,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=eop_WinEventLog:Application
| eval Friendly=$Friend$
| lookup Friendly_Name.csv Friendly OUTPUT FullHost
| lookup Friendly_Name.csv Friendly OUTPUT FullHostHSB
host IN (FullHost, FullHostHSB) Message="OMIS $omis01$" OR TaskCategory="omis $omis01$"
Type IN ($Type01$)

| table _time host TaskCategory Type EventCode Message
| sort - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Doesn't work because 'host IN...' is out of place.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=eop_WinEventLog:Application

`FriendlyEval`

| where (host IN (FullHost, FullHostHSB) Message="OMIS $omis01$" OR TaskCategory="omis $omis01$"
AND Type IN ($Type01$))
| table _time host TaskCategory Type EventCode Message
| sort - _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Feb 2020 18:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477435#M133989</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-02-21T18:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calling an eval-macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477436#M133990</link>
      <description>&lt;P&gt;First, you don't need two calls to your lookup - you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup Friendly_Name.csv Friendly OUTPUT FullHost FullHostHSB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Secondly, what prevents you from doing this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=eop_WinEventLog:Application `FriendlyEval`
| &amp;lt;rest of your search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Feb 2020 18:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Calling-an-eval-macro/m-p/477436#M133990</guid>
      <dc:creator>wmyersas</dc:creator>
      <dc:date>2020-02-21T18:48:55Z</dc:date>
    </item>
  </channel>
</rss>

