<?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: Map command subsearch results loosing initial search value from the output in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625969#M217580</link>
    <description>&lt;P&gt;Firstly - ughhhh... Not only you use map which &lt;U&gt;should not be used unless it absolutely cannot be avoided&lt;/U&gt;. And it should not be run with big datasets.&lt;/P&gt;&lt;P&gt;If you run your search built properly, offloading as much processing as possible to indexers, you're splitting your work across your whole deployment. If you do "tricks" like subsearches and map, you spawn multiple searches, bounce the data back and forth between search heads and indexers and generally make it as inefficient as can be &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And additionally, in your original search you use wildcard at the beginning of your match term. No wonder it's taking forever to finish since it has to scan all events!&lt;/P&gt;&lt;P&gt;But secondly - in your search spawned from the map command the token is effectively substituted "directly" with given string. So you're getting something like&lt;/P&gt;&lt;PRE&gt;| eval resultfield=TextString&lt;/PRE&gt;&lt;P&gt;Which most probably is not what you need because you're trying to set value of resultfield to a value of a field called TextString instead of TextString itself.&lt;/P&gt;&lt;P&gt;So you need to do&lt;/P&gt;&lt;PRE&gt;| eval resultfield=\"$field1$\"&lt;/PRE&gt;&lt;P&gt;And this does work.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2023 09:09:15 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-01-05T09:09:15Z</dc:date>
    <item>
      <title>Map command subsearch results losing initial search value from the output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625515#M217435</link>
      <description>&lt;P&gt;Here is an example of SPL I am trying to run.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval ProxyUser="User1,User2,User3"
| makemv delim="," ProxyUser
| mvexpand ProxyUser
| map maxsearches=0 search="search index=edrlogs* SubjectName=*$ProxyUser$ earliest=-24h | eval ProxyUser1=$ProxyUser$"
| fillnull value="N/A"
| table _time SubjectName EndpointName IPAddress ProxyUser1&lt;/LI-CODE&gt;
&lt;P&gt;I am getting results, however the ProxyUser1 field is empty. The initial searched value of&amp;nbsp;&lt;SPAN&gt;ProxyUser has been&amp;nbsp; eval'd to a new field named ProxyUser1, within the map command. I have read some other posts where the eval command after the map search should do the trick, but I believe I am doing something wrong here&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Any leads would be much appreciated&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 04:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625515#M217435</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2023-01-06T04:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625516#M217436</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183570"&gt;@sureshtskumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;why don't you use the first part in a subsearch?&lt;/P&gt;&lt;P&gt;somethng like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=edrlogs* SubjectName=*$ProxyUser$ earliest=-24h [ | makeresults
| eval ProxyUser="User1,User2,User3" | makemv delim="," ProxyUser | mvexpand ProxyUser | eval SubjectName="*"."ProxyUser | fields SubjectName ]
| fillnull value="N/A"
| table _time SubjectName EndpointName IPAddress ProxyUser1&lt;/LI-CODE&gt;&lt;P&gt;see my approach and adapt it to your need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:17:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625516#M217436</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-12-30T10:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625518#M217437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;ThankYou so much for the response. Just to give you a little more insight, the ProxyUser parameter values are obtained from the first search in a network index (although I am just using makeresults to simulate those users). This list of users from the network index is then passed on to an EDR index to get the hostname these users use. So ideally, this should look as:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=proxy domain="somebad.com" earliest=-24h&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;| stats values(ProxyUser) as ProxyUser&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| map maxsearches=0 search="search index=edrlogs SubjectName=*&lt;/SPAN&gt;&lt;STRONG&gt;$ProxyUser$&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;earliest=-24h |&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;eval ProxyUser1=$ProxyUser$&lt;/STRONG&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fillnull value="N/A"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| table _time SubjectName EndpointName IPAddress&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;ProxyUser1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So the values _time,&amp;nbsp;&lt;SPAN&gt;SubjectName, EndpointName and IPAddress are all coming from EDR logs and I want to retain the original username from the first proxylogs index, which is ProxyUser1. This is where the values are getting empty. Hope this clarifies&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:24:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625518#M217437</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2022-12-30T10:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625519#M217438</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183570"&gt;@sureshtskumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you need to extract values from two indexes correlating events from both the indexes, you can use the transaction command, but I use this solution only when I haven't any other choice because it's very slow.&lt;/P&gt;&lt;P&gt;Please try this different approach using stats:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=proxy domain="somebad.com") OR (index=edrlogs) earliest=-24h
| rename ProxyUser AS SubjectName
| stats 
   earliest(_time) AS _time 
   values(EndpointName) AS EndpointName
   values(IPAddress) AS IPAddress
   dc(index) AS index_count
   BY SubjectName 
| where index_count&amp;gt;1&lt;/LI-CODE&gt;&lt;P&gt;in this way you have the fields of only ProxyUsers that are in both the indexes.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625519#M217438</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-12-30T10:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625520#M217439</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;thanks again for your kind response.&lt;/P&gt;&lt;P&gt;That search query is very expensive and my search times out as the edr index is humongous. So this couldnot be tested in the actual environment.&lt;/P&gt;&lt;P&gt;I would rather need a search where the usernames are restricted to those who visited the somebad.com domain as seen in the proxy logs, then pipe it to the EDR logs. The very reason why I am using the map command is that I can add more values from the first search in the proxy logs, such as the earliest/latest time this traffic was seen. This would help in pinpointing to the user especially when a shared machine is being investigated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:40:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625520#M217439</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2022-12-30T10:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625522#M217440</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183570"&gt;@sureshtskumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;add these additional conditions to the main search to limit results.&lt;/P&gt;&lt;P&gt;I'd like that you understand the approach and adapt it to your needs.&lt;/P&gt;&lt;P&gt;ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625522#M217440</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-12-30T10:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625525#M217441</link>
      <description>&lt;P class="lia-align-left"&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; Thanks for the reply. Unfortunately that search&amp;nbsp; doesn't return any hits. I will keep troubleshooting and let you know if I find where I am messing up&lt;/P&gt;&lt;P&gt;(index=proxy domain="somebad.com") OR (index=edrlogs) earliest=-24h&lt;BR /&gt;| rename ProxyUser AS SubjectName&lt;BR /&gt;| stats&lt;BR /&gt;earliest(_time) AS _time&lt;BR /&gt;values(EndpointName) AS EndpointName&lt;BR /&gt;values(IPAddress) AS IPAddress&lt;BR /&gt;dc(index) AS index_count&lt;BR /&gt;BY SubjectName&lt;BR /&gt;| where index_count&amp;gt;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 11:01:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625525#M217441</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2022-12-30T11:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625526#M217442</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183570"&gt;@sureshtskumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you should anakyze the correlation key to understand if there are matching values in the two fields.&lt;/P&gt;&lt;P&gt;If not, you have to find a common part of those fields.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 11:56:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625526#M217442</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-12-30T11:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625527#M217443</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;@Will get my head around the suggested query. Meanwhile if you can find out what is breaking my original map command, especially why is the value from the first search not retained in the final output of the second search, it would be really helpful. Have seen others raising similar question with the map command and so far haven’t seems any good reason as to why this happens&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 12:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625527#M217443</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2022-12-30T12:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625933#M217571</link>
      <description>&lt;P&gt;This is finally found to be a potential bug or atleast a limitation in the map command. I went ahead and performed some very generic searches in Splunk using the map command to pass three types of data to be searched in the map subsearch; text, numbers, alpanumeric with special characters. The results of the test shows that any values containing pure text strings (no numbers, no special characters) that are passed on to the map command cannot be recovered in the search results.&lt;/P&gt;&lt;P&gt;Here is the proof:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Query Used for test:&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;| makeresults&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;| eval field1="TextString", field2="12345", field3="user@12345mail.com"&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;| table field1, field2, field3&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;| map maxsearches=300 search="search index=_internal ($field1$ OR $field2$ OR $field3$) earliest=-2h | eval TextString=$field1$, Number=$field2$, Alphanum=$field3$"&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;| table _time index TextString Number Alphanum&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;Results:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;Notice the TextString field is empty while the number and alphanumeric and special character values are all retained in the output.&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I will try and bring this to Splunk's attention, however not sure if this is going to be fixed or left as is. Thanks to all who took the time to read through and helped with suggestions&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_Map_Limitation.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/23201i2722F69E12F96AC1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_Map_Limitation.png" alt="Splunk_Map_Limitation.png" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 03:23:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625933#M217571</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2023-01-05T03:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625957#M217575</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183570"&gt;@sureshtskumar&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 08:25:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625957#M217575</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-01-05T08:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625969#M217580</link>
      <description>&lt;P&gt;Firstly - ughhhh... Not only you use map which &lt;U&gt;should not be used unless it absolutely cannot be avoided&lt;/U&gt;. And it should not be run with big datasets.&lt;/P&gt;&lt;P&gt;If you run your search built properly, offloading as much processing as possible to indexers, you're splitting your work across your whole deployment. If you do "tricks" like subsearches and map, you spawn multiple searches, bounce the data back and forth between search heads and indexers and generally make it as inefficient as can be &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And additionally, in your original search you use wildcard at the beginning of your match term. No wonder it's taking forever to finish since it has to scan all events!&lt;/P&gt;&lt;P&gt;But secondly - in your search spawned from the map command the token is effectively substituted "directly" with given string. So you're getting something like&lt;/P&gt;&lt;PRE&gt;| eval resultfield=TextString&lt;/PRE&gt;&lt;P&gt;Which most probably is not what you need because you're trying to set value of resultfield to a value of a field called TextString instead of TextString itself.&lt;/P&gt;&lt;P&gt;So you need to do&lt;/P&gt;&lt;PRE&gt;| eval resultfield=\"$field1$\"&lt;/PRE&gt;&lt;P&gt;And this does work.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 09:09:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625969#M217580</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-01-05T09:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Map command subsearch results loosing initial search value from the output</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625988#M217585</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;for taking the time and effort to respond.&lt;/P&gt;&lt;P&gt;I am personally not a fan of map command and am using it as it appeared to be the best option to pass multiple parameters from the main search to multiple other indexes to get the final output. The solution to the issue I was facing with map command wasn’t documented anywhere, and it did appear to be a bug/limitation in handling certain type of data while other types were handled correctly. &amp;nbsp;Hope it clarifies&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 11:36:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Map-command-subsearch-results-losing-initial-search-value-from/m-p/625988#M217585</guid>
      <dc:creator>sureshtskumar</dc:creator>
      <dc:date>2023-01-05T11:36:45Z</dc:date>
    </item>
  </channel>
</rss>

