<?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: Passing a value from one search to another (map? subsearch? join?) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125649#M33962</link>
    <description>&lt;P&gt;The stars aren't showing on my above post. but I realised I don't need then as  its a regex anyway.&lt;/P&gt;

&lt;P&gt;Anyway, I'm getting somewhere now after you guy's help. I just need to make it sort the 'MarkedasJunk' column and remove any rows which equal 0.&lt;/P&gt;</description>
    <pubDate>Fri, 29 May 2015 13:21:35 GMT</pubDate>
    <dc:creator>chris24747</dc:creator>
    <dc:date>2015-05-29T13:21:35Z</dc:date>
    <item>
      <title>Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125641#M33954</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;This is my first question - usually I've been able to figure it out following posts on here but I'm struggling with this one a little as I'm struggling to get my head around joins, sub-searches and maps.&lt;/P&gt;

&lt;P&gt;What i am trying to do is search through my e-mail message tracking logs and identify the top 10 subject lines of a message and is marked as junk. Then i want to do the same search but based on the message subject where it hasn't been flagged as junk. I then want it shown in a table as per&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MessageSubject     Count of mails marked as junk    Count of mails not marked as junk
subject 1                        10                                 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this should show only the top 10 (or whatever i change it to) that have been marked as junk, the number not marked as junk is just for reference, no sorting etc required. &lt;BR /&gt;
So far i have tried Join:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_index=msgtrack event_id=DELIVER | stats count as MarkedAsJunk  | join message_subject [search index=msgtrack recipient_status="*&amp;lt;Junk Email&amp;gt;*" event_id=DELIVER | top limit=10 message_subject | stats count as NotFilteredOut] | table message_subject MarkedAsJunk NotFilteredOut_
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;map&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_index=msgtrack recipient_status="*&amp;amp;lt;Junk Email&amp;amp;gt;*" event_id=DELIVER | top limit=10 message_subject | map maxsearches=2000 search="index=msgtrack event_id=DELIVER message_subject=$message_subject$ | stats count as NotFilteredOut"_  (work in progress)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;subsearch&lt;BR /&gt;
(didnt save this one, sorry)&lt;/P&gt;

&lt;P&gt;Any pointers would be great, at the moment I'm not even sure which approach I should be coming from.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 10:17:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125641#M33954</guid>
      <dc:creator>chris24747</dc:creator>
      <dc:date>2015-05-29T10:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125642#M33955</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=msgtrack recipient_status="&amp;lt;Junk Email&amp;gt;" event_id=DELIVER | top limit=10 message_subject | map maxsearches=2000 search="index=msgtrack event_id=DELIVER message_subject=\"$message_subject$\" | stats count AS all count(eval(recipient_status="&amp;lt;Junk Email&amp;gt;") AS junk BY message_subject
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 May 2015 12:08:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125642#M33955</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-29T12:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125643#M33956</link>
      <description>&lt;P&gt;You crazy kids make things sofa king hard sometimes!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=msgtrack event_id=DELIVER 
| stats count(eval(recipient_status=="&amp;lt;Junk Email&amp;gt;")) as MarkedAsJunk,  count(eval(NOT (recipient_status=="&amp;lt;Junk Email&amp;gt;"))) AS NotFilteredOut by message_subject 
| sort - MarkedAsJunk
| head 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does that do what you want? Always do things in a single pass if you can, unless you need long-term trending.&lt;/P&gt;

&lt;P&gt;The example with &lt;CODE&gt;map&lt;/CODE&gt; is &lt;EM&gt;terrible&lt;/EM&gt;, as it causes a total of 11 distinct searches to be dispatched.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:31:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125643#M33956</guid>
      <dc:creator>jacobwilkins</dc:creator>
      <dc:date>2015-05-29T12:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125644#M33957</link>
      <description>&lt;P&gt;thanks for the response.. So i dont get any Parsing errors with this but i get an error on the job (one that i've seen before, so i must have been on the right track. the error says "Unable to run query 'index=msgtrack event_id=DELIVER message_subject="Gardeners 250ml Hand Therapy | Back by popular demand" | stats count AS all count(eval(recipient_status='&lt;EM&gt;&amp;lt;Junk Email&amp;gt;&lt;/EM&gt;') AS junk BY message_subject'."&lt;/P&gt;

&lt;P&gt;the good news is that the message subject that has been added to the search is the top result from the first search, so this is close but something else is going on. Which log file do i need to look into to find this error?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:03:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125644#M33957</guid>
      <dc:creator>chris24747</dc:creator>
      <dc:date>2020-09-28T20:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125645#M33958</link>
      <description>&lt;P&gt;I re-edited the original answer to add double-quotes around the subject string so parts of it will not be interpreted as commands; try updated answer.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:43:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125645#M33958</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-29T12:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125646#M33959</link>
      <description>&lt;P&gt;See, this is why i ended up asking! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Getting close.  I typo'd my above search, i need the recipient_status to equal "&lt;EM&gt;&amp;lt;Junk EMail&amp;gt;&lt;/EM&gt;" (ie adding the additional wildcards) which eval is not going to like!&lt;/P&gt;

&lt;P&gt;(Ive got a star (ie shift+8) either side of the &amp;lt;Junk Email&amp;gt; above, but within the quotes. This page wont display it.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:44:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125646#M33959</guid>
      <dc:creator>chris24747</dc:creator>
      <dc:date>2015-05-29T12:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125647#M33960</link>
      <description>&lt;P&gt;still the same error, i've also tried making the =  to == in the eval() to no avail. When i inspect the job i can see that the quotes are being escaped ok.  For what it's worth i expect its going to be this way, with a map, thats going to get me what i want. &lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125647#M33960</guid>
      <dc:creator>chris24747</dc:creator>
      <dc:date>2015-05-29T12:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125648#M33961</link>
      <description>&lt;P&gt;What wildcards? &lt;/P&gt;

&lt;P&gt;Just a case sensitivity issue with the string?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count(eval(match(recipient_status,"(?i)&amp;amp;lt;Junk Email&amp;amp;gt;"))) as MarkedAsJunk,  count(eval(NOT (match(recipient_status,"(?i)&amp;amp;lt;Junk Email&amp;amp;gt;")))) AS NotFilteredOut by message_subject 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I usually use &lt;CODE&gt;match()&lt;/CODE&gt;in that context anyway, the differences between &lt;CODE&gt;==&lt;/CODE&gt;and &lt;CODE&gt;=&lt;/CODE&gt;can be confusing. You could probably also use &lt;CODE&gt;searchmatch()&lt;/CODE&gt;, which might make wildcarding easier if you aren't down with regular expressions.&lt;/P&gt;

&lt;P&gt;Really, you have tons of options.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart count over message_subject by recipient_status 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;^^ Another approach. &lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:59:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125648#M33961</guid>
      <dc:creator>jacobwilkins</dc:creator>
      <dc:date>2015-05-29T12:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a value from one search to another (map? subsearch? join?)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125649#M33962</link>
      <description>&lt;P&gt;The stars aren't showing on my above post. but I realised I don't need then as  its a regex anyway.&lt;/P&gt;

&lt;P&gt;Anyway, I'm getting somewhere now after you guy's help. I just need to make it sort the 'MarkedasJunk' column and remove any rows which equal 0.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 13:21:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Passing-a-value-from-one-search-to-another-map-subsearch-join/m-p/125649#M33962</guid>
      <dc:creator>chris24747</dc:creator>
      <dc:date>2015-05-29T13:21:35Z</dc:date>
    </item>
  </channel>
</rss>

