<?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: Splunk search with multiple macros in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575406#M200509</link>
    <description>&lt;P&gt;Thanks, it is exactely what I was afraid of.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Nov 2021 09:19:16 GMT</pubDate>
    <dc:creator>SIEMStudent</dc:creator>
    <dc:date>2021-11-18T09:19:16Z</dc:date>
    <item>
      <title>Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575268#M200460</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a question about macros: suppose I must use, inside a search, multiple macros. Those macros can be related between them by simple logical condition like AND and OR; what is the right syntax to tell to search to use more than one macro? Is the append command or other?&lt;/P&gt;&lt;P&gt;UPDATE&lt;BR /&gt;&lt;BR /&gt;Let me modify the post, after&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;explaination.&lt;BR /&gt;&lt;BR /&gt;The current desiderd behavior is to perform security check with rules that uses multiple macros. We don't know if it is the best way and/or absolutely required by customer, but at writing time is our guideline.&lt;BR /&gt;&lt;BR /&gt;We have the following situation:&lt;BR /&gt;&lt;BR /&gt;1. Two or more macros linked with AND operator. Consider the following macros:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`remote to local` = | eval (All_traffic.src) as src from datamodel="Network traffic"| eval (All_traffic.dest) as dest from datamodel="Network traffic" |where ( src!=10.0.0.0/8 AND src!=172.16.0.0/12 AND src!=192.168.0.0/16) AND ( dest=10.0.0.0/8 OR dest=172.16.0.0/12 OR dest=192.168.0.0/16) &lt;/LI-CODE&gt;&lt;P&gt;set to use Data Model instead of raw events and that evaluate if the connection is from internet to local network.&lt;BR /&gt;&lt;BR /&gt;The other one is the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`successfull communication` = | eval(All_traffic.bytes_in/All_traffic.packets_in) as input_rate from datamodel="Network traffic" | eval(All_traffic.bytes_out/All_traffic.packets_out) as output_rate from datamodel="Network traffic" | where input_rate &amp;gt; 80 and output_rate &amp;gt; 80&lt;/LI-CODE&gt;&lt;P&gt;which try to understand if the communication between source and dest works fine counting the bytes/packets rate.&lt;BR /&gt;&lt;BR /&gt;What about if, in my&amp;nbsp; rules, I have to use them linked with AND and used as filter? I mean, the final rule structure is something like that:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;my search&amp;gt;....| where `remote to local` AND `successfull communication`&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;2. The Macros should be putted togheter with OR. This becaus the rule try multiple way to understand if something is happening or not.&lt;BR /&gt;&lt;BR /&gt;Consider this macros:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`IRC Check with Firewalls`=|tstats count values(All_traffic.src) as source by source from datamodel=Network_Traffic|where  All_traffic.protocol = tcp AND All_traffic.action = allowed | search All_traffic.dest = NOT [| inputlookup WhiteListIP.csv | table dest] All_traffic.dest_port IN  [| inputlookup IRCPorts.csv | table dest_port]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;that try to check if a IRC server is in execution checking some network data, like firewall pass, tcp protocol, destination port present in IRCPorts.csv file and excluding some authorized server putted in WhitelistIP.csv.&lt;BR /&gt;&lt;BR /&gt;Then, we must make a macros that try to find if an IRC client is in execution; currently we don't know how to realize this, so let me put here simply its name:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;`IRC Client Detected`&lt;/LI-CODE&gt;&lt;P&gt;So, the final search whant use this 2 macros as filter and trigger if one of them is true; something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;some search&amp;gt;...| where `IRC Check with Firewalls` OR `IRC Client Detected`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Any combination between AND and OR. Using the above macros, something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;some search&amp;gt;...| where `remote to local` AND (`IRC Check with Firewalls` OR `IRC Client Detected`)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 08:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575268#M200460</guid>
      <dc:creator>SIEMStudent</dc:creator>
      <dc:date>2021-11-18T08:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575278#M200463</link>
      <description>&lt;P&gt;Macros are just a way of shortening the SPL code - you can use &amp;lt;ctrl&amp;gt;&amp;lt;shift&amp;gt;E in the search box to expand the macros - the expanded macros have to still form valid SPL. This is a long way of saying, it depends on your macros and what they do!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 14:24:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575278#M200463</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-17T14:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575287#M200464</link>
      <description>&lt;P&gt;You are right, my fault, I apologize.&lt;/P&gt;&lt;P&gt;The macro I have to create are used by Security Use Cases and so are used to determine if the rule must trigger or not. Normally, I have 2 possibility:&lt;/P&gt;&lt;P&gt;1. The macro can call, inside it, another macro&lt;BR /&gt;&lt;BR /&gt;As example, suppose I have this 2 macros:&lt;BR /&gt;&lt;BR /&gt;a.&amp;nbsp;`communication request` which notify if a communication request has been done; if yes, it calls:&lt;BR /&gt;b.&amp;nbsp;`communication successfull` that state if the communication has worked fine.&lt;BR /&gt;&lt;BR /&gt;In this case, should I use a syntax like&amp;nbsp;`communication request` append&amp;nbsp;`communication successfull`?&lt;/P&gt;&lt;P&gt;2. The Macro does not call another macro inside it, but the rule need multiple one to decide if activate or not.&lt;/P&gt;&lt;P&gt;As example, suppose I have to detect if a IRC local Server is founded and for this I have 3 macros:&lt;BR /&gt;&lt;BR /&gt;a.&amp;nbsp;&amp;nbsp;`remote to local`, used to determine if the connection has remote src and local dest address&lt;BR /&gt;b.&amp;nbsp;`firewall pass`, used to determine if on this connection I have a firewall pass&lt;BR /&gt;c.&amp;nbsp;`application used`, which determine the application used to connect to IRC server&lt;BR /&gt;&lt;BR /&gt;In this case, the 3 macros must be divided with pipe? Something like:&lt;BR /&gt;|`remote to local` |`firewall pass` |`application used`&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 15:25:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575287#M200464</guid>
      <dc:creator>SIEMStudent</dc:creator>
      <dc:date>2021-11-17T15:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575300#M200471</link>
      <description>&lt;P&gt;It depends on what the macros expand to - you haven't provided this information so it is not possible to say how the macros should be used.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 16:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575300#M200471</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-17T16:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575388#M200501</link>
      <description>&lt;P&gt;I understand. So let me update my starting post to better explain the scenario, with same sample macros.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 08:13:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575388#M200501</guid>
      <dc:creator>SIEMStudent</dc:creator>
      <dc:date>2021-11-18T08:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575403#M200507</link>
      <description>&lt;P&gt;The macros don't look like they would expand to valid syntax to be used in a where clause as you described. Perhaps you should try constructing the search query without macros first to get the results you require, then work out which bits can be converted to macros.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 09:06:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575403#M200507</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-18T09:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search with multiple macros</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575406#M200509</link>
      <description>&lt;P&gt;Thanks, it is exactely what I was afraid of.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 09:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-search-with-multiple-macros/m-p/575406#M200509</guid>
      <dc:creator>SIEMStudent</dc:creator>
      <dc:date>2021-11-18T09:19:16Z</dc:date>
    </item>
  </channel>
</rss>

