<?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: Any example for MAP command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88478#M22640</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/121510"&gt;@manish_singh_77&lt;/a&gt;7,&lt;/P&gt;

&lt;P&gt;I'm not sure what you mean but I think you might want to take a look at working with Splunk using XML and the APIs?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:07:33 GMT</pubDate>
    <dc:creator>koenV</dc:creator>
    <dc:date>2020-09-29T20:07:33Z</dc:date>
    <item>
      <title>Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88473#M22635</link>
      <description>&lt;P&gt;Can i have a sample of MAP command?&lt;BR /&gt;
Please give sample events and final outputs also.&lt;BR /&gt;
I'm not able to understand doc provided by splunk.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2012 10:25:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88473#M22635</guid>
      <dc:creator>ma_anand1984</dc:creator>
      <dc:date>2012-10-12T10:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88474#M22636</link>
      <description>&lt;P&gt;Map is like a foreach iterator. It will take each "result" of a previous search, and perform the map search that many times with the specified map search. An example might help.&lt;/P&gt;

&lt;P&gt;So I have a search (let's call it &lt;CODE&gt;SRCH_1&lt;/CODE&gt;) "&lt;CODE&gt;sourcetype=syslog sudo|stats count by user host&lt;/CODE&gt;"&lt;BR /&gt;
This returns a table such as:&lt;/P&gt;

&lt;TABLE&gt;
  &lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;user&lt;/TD&gt;&lt;TD&gt;host&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;user1&lt;/TD&gt;&lt;TD&gt;server1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;user3&lt;/TD&gt;&lt;TD&gt;server1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;user1&lt;/TD&gt;&lt;TD&gt;server3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;Right after &lt;CODE&gt;SRCH_1&lt;/CODE&gt;, we will pipe, and then add the map command (&lt;CODE&gt;SRCH_MAP&lt;/CODE&gt; it shall be known as): &lt;CODE&gt;|map search="search index=ad_summary username=$user$ type_logon=ad_last_logon"&lt;/CODE&gt;. This command will take each of the three results above, and search in my ad_summary index for a user logon event. The results are returned as a table and look like this(ish):&lt;/P&gt;

&lt;TABLE&gt;
&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;computername&lt;/TD&gt;&lt;TD&gt;computertime&lt;/TD&gt;&lt;TD&gt;username&lt;/TD&gt;&lt;TD&gt;usertime&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;10/12/12 8:31:35.00 AM&lt;/TD&gt;&lt;TD&gt;ADMIN28-H$&lt;/TD&gt;&lt;TD&gt;10/12/2012 08:25:42&lt;/TD&gt;&lt;TD&gt;user1&lt;/TD&gt;&lt;TD&gt;10/12/2012 08:31:35 AM&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;What this is doing, putting it together, is finding who sudo'd and then tracing back to the computer and time they logged on to prior to the sudo event. &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;EDIT:&lt;/EM&gt;&lt;BR /&gt;
Here is the complete search: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=syslog sudo|stats count by user host|map search="search index=ad_summary username=$user$ type_logon=ad_last_logon"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2012 13:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88474#M22636</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-10-12T13:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88475#M22637</link>
      <description>&lt;P&gt;What is the advantage of this over using a "join" command:&lt;/P&gt;

&lt;P&gt;sourcetype=syslog sudo | stats count by user host | join user [ search index=ad_summary type_logon=ad_last_logon username=* | rename username AS user]&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:43:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88475#M22637</guid>
      <dc:creator>rtadams89</dc:creator>
      <dc:date>2020-09-28T16:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88476#M22638</link>
      <description>&lt;P&gt;There is not necessarily an advantage. Especially for large 'outer' searches the &lt;CODE&gt;map&lt;/CODE&gt; command is very slow (and so is &lt;CODE&gt;join&lt;/CODE&gt; - your example could also be done using &lt;CODE&gt;stats&lt;/CODE&gt; only). &lt;BR /&gt;
However, keep in mind that the &lt;CODE&gt;map&lt;/CODE&gt; function returns &lt;EM&gt;only&lt;/EM&gt; the results from the search specified in the &lt;CODE&gt;map&lt;/CODE&gt; command, whereas a &lt;CODE&gt;join&lt;/CODE&gt; will return results from &lt;EM&gt;both&lt;/EM&gt; searches.&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 11:23:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88476#M22638</guid>
      <dc:creator>koenV</dc:creator>
      <dc:date>2018-05-01T11:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88477#M22639</link>
      <description>&lt;P&gt;Hi Alacercogitatus,&lt;/P&gt;

&lt;P&gt;Can we use map command to pass variable value in rest end point?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 06:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88477#M22639</guid>
      <dc:creator>manish_singh_77</dc:creator>
      <dc:date>2018-06-22T06:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Any example for MAP command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88478#M22640</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/121510"&gt;@manish_singh_77&lt;/a&gt;7,&lt;/P&gt;

&lt;P&gt;I'm not sure what you mean but I think you might want to take a look at working with Splunk using XML and the APIs?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:07:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-example-for-MAP-command/m-p/88478#M22640</guid>
      <dc:creator>koenV</dc:creator>
      <dc:date>2020-09-29T20:07:33Z</dc:date>
    </item>
  </channel>
</rss>

