<?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: Newbie map question in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312685#M40046</link>
    <description>&lt;P&gt;If you use &lt;CODE&gt;search="&lt;/CODE&gt; syntax you have to escape any &lt;CODE&gt;"&lt;/CODE&gt; in your search, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |inputlookup My_Test_Extraction_Lookups 
  |table stanza
  |map search="| rest splunk_server=local /servicesNS/-/-/data/ui/views 
  | rex field=eai:data \"(sourcetype=)+(?&amp;lt;sourcetype&amp;gt;\w+)\s\" max_match=0
  | rename eai:data as code eai:acl.owner as owner eai:acl.app as app 
  |stats values(*) as * by sourcetype
  |search sourcetype=$stanza$
  | table sourcetype title owner app"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And &lt;CODE&gt;| map [&amp;lt;search&amp;gt;]&lt;/CODE&gt; is indeed valid.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 20:44:40 GMT</pubDate>
    <dc:creator>micahkemp</dc:creator>
    <dc:date>2018-01-19T20:44:40Z</dc:date>
    <item>
      <title>Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312680#M40041</link>
      <description>&lt;P&gt;I'm just starting to play with the joys of a Map command, but I can't seem to find the right way to do it.  I'm using a test lookup file, and only trying to match one value off it.&lt;/P&gt;

&lt;P&gt;Can someone give me some direction, please?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup My_Test_Extraction_Lookups 
|table stanza 
|map [| rest splunk_server=local /servicesNS/-/-/data/ui/views 
| rex field=eai:data "(sourcetype=)+(?&amp;lt;sourcetype&amp;gt;\w+)\s" max_match=0
| rename eai:data as code eai:acl.owner as owner eai:acl.app as app 
|stats values(*) as * by sourcetype 
| where sourcetype=$stanza$ 
| table sourcetype title owner app] 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 19:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312680#M40041</guid>
      <dc:creator>sheltomt</dc:creator>
      <dc:date>2018-01-19T19:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312681#M40042</link>
      <description>&lt;P&gt;I think you may need to include some additional information about the problem you're running into.  Is the search giving you an error, incomplete results, or incorrect results?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312681#M40042</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-19T20:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312682#M40043</link>
      <description>&lt;P&gt;I apologize, it is returning 0 results.  I should have ~80 records in the lookup to check against, and I should have about 140ish total records in the end&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:14:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312682#M40043</guid>
      <dc:creator>sheltomt</dc:creator>
      <dc:date>2018-01-19T20:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312683#M40044</link>
      <description>&lt;P&gt;your syntax is just a little off. &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Map"&gt;https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Map&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |inputlookup My_Test_Extraction_Lookups 
 |table stanza
 |map search="| rest splunk_server=local /servicesNS/-/-/data/ui/views 
 | rex field=eai:data "(sourcetype=)+(?&amp;lt;sourcetype&amp;gt;\w+)\s" max_match=0
 | rename eai:data as code eai:acl.owner as owner eai:acl.app as app 
 |stats values(*) as * by sourcetype
 |search sourcetype=$stanza$
 | table sourcetype title owner app"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:40:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312683#M40044</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-01-19T20:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312684#M40045</link>
      <description>&lt;P&gt;In my environment, both syntax structures work - but using the &lt;CODE&gt;map search="..."&lt;/CODE&gt; structure does require escaping all double-quotes within the search. &lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:43:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312684#M40045</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-01-19T20:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312685#M40046</link>
      <description>&lt;P&gt;If you use &lt;CODE&gt;search="&lt;/CODE&gt; syntax you have to escape any &lt;CODE&gt;"&lt;/CODE&gt; in your search, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  |inputlookup My_Test_Extraction_Lookups 
  |table stanza
  |map search="| rest splunk_server=local /servicesNS/-/-/data/ui/views 
  | rex field=eai:data \"(sourcetype=)+(?&amp;lt;sourcetype&amp;gt;\w+)\s\" max_match=0
  | rename eai:data as code eai:acl.owner as owner eai:acl.app as app 
  |stats values(*) as * by sourcetype
  |search sourcetype=$stanza$
  | table sourcetype title owner app"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And &lt;CODE&gt;| map [&amp;lt;search&amp;gt;]&lt;/CODE&gt; is indeed valid.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:44:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312685#M40046</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-19T20:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312686#M40047</link>
      <description>&lt;P&gt;This is a great example of a search that can be restructured to not use the &lt;CODE&gt;map&lt;/CODE&gt; command at all. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Why you should avoid using &lt;CODE&gt;map&lt;/CODE&gt; whenever possible&lt;/STRONG&gt;&lt;BR /&gt;
The &lt;CODE&gt;map&lt;/CODE&gt; command launches a new search for every line of input that is piped to it. So if the primary search feeding into your &lt;CODE&gt;map&lt;/CODE&gt; command has 100 lines, then Splunk will launch 100 new searches. (Technically, it will actually only launch 10, unless you use the &lt;CODE&gt;maxsearches&lt;/CODE&gt; option, because &lt;CODE&gt;map&lt;/CODE&gt; will default to &lt;CODE&gt;maxsearches=10&lt;/CODE&gt;. But still.) This is tremendously resource-intensive, so &lt;CODE&gt;map&lt;/CODE&gt; should be your last option, and you should take great care to see if your searches can be restructured to not use it.&lt;/P&gt;

&lt;P&gt;So here's an attempt to restructure your search to not use &lt;CODE&gt;map&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest splunk_server=local /servicesNS/-/-/data/ui/views 
| rex field=eai:data "(sourcetype=)+(?&amp;lt;sourcetype&amp;gt;\w+)\s" max_match=0
| rename eai:data as code eai:acl.owner as owner eai:acl.app as app 
| stats values(*) as * by sourcetype 
| lookup My_Test_Extraction_Lookups stanza AS sourcetype OUTPUT stanza AS found
| where isnotnull(found)
| table sourcetype title owner app
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I've done here is change this into a single pipelined search and used the lookup file to actually perform lookups against the results of that &lt;CODE&gt;rest&lt;/CODE&gt; call. Since you were only using the &lt;CODE&gt;stanza&lt;/CODE&gt; value to match against the &lt;CODE&gt;sourcetype&lt;/CODE&gt; value, it was pretty straightforward to translate the &lt;CODE&gt;inputlookup&lt;/CODE&gt; command into a &lt;CODE&gt;lookup&lt;/CODE&gt; call further down the pipeline. I output the &lt;CODE&gt;stanza&lt;/CODE&gt; value in a new field called &lt;CODE&gt;found&lt;/CODE&gt; and use it as a flag in the next step to save only the results where the pseudo-flag of &lt;CODE&gt;found&lt;/CODE&gt; is present.&lt;/P&gt;

&lt;P&gt;If this still doesn't give you the results you're looking for, I'm happy to help troubleshoot with some more details.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:57:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312686#M40047</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-01-19T20:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312687#M40048</link>
      <description>&lt;P&gt;Thank you for the explanation and code!&lt;/P&gt;

&lt;P&gt;I'll use this for further automation; I did it manually this time around but will definitely use the lookup table as you suggest next time.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:20:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312687#M40048</guid>
      <dc:creator>sheltomt</dc:creator>
      <dc:date>2018-01-22T14:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie map question</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312688#M40049</link>
      <description>&lt;P&gt;Happy to help! When I first discovered the &lt;CODE&gt;map&lt;/CODE&gt; command, I thought I'd finally found the answer to all my SPL pains, and it took me a while to find out why this magical new command was grinding my searches to a halt. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Newbie-map-question/m-p/312688#M40049</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-01-22T14:37:36Z</dc:date>
    </item>
  </channel>
</rss>

