<?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: How do you search a value from one query in another second query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405287#M117153</link>
    <description>&lt;P&gt;When using map function please change maxsearches.&lt;/P&gt;

&lt;P&gt;In order to change the search sentence, the difficulty level changes with how to hold filed1.&lt;BR /&gt;
Does Query2(jhdahbd_hdhc) submit filed1? Can you search by keyword search only?&lt;/P&gt;

&lt;P&gt;search index=ajhdahbd_hdhc  $field1$&lt;BR /&gt;&lt;BR /&gt;
↓&lt;BR /&gt;
search index=ajhdahbd_hdhc  (field1="XX" OR  field1="YY" ･･･)   &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:25:22 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2020-09-29T21:25:22Z</dc:date>
    <item>
      <title>How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405282#M117148</link>
      <description>&lt;P&gt;We have two different search queries with no unique fields and we would like to get the below info: &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;we would like to search the value which we get in first query in the second query.  &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;if the value in first query is present in second query then we would like to print both the events .&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;For example, we tried the below, but we were unable to get both the events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abcde_yudhbc  "Sending message to queue"  | dedup field1 | stats count by field1| map search="search index=ajhdahbd_hdhc  $field1$  Successfully pushed to system "
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whatever list of values we get for field1, we would like to pass each field1 value to the second query using the map command. And, if the field1 value is present, then we would like to display both the field1 value and the event which is matched in the second search. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 23:07:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405282#M117148</guid>
      <dc:creator>dsha</dc:creator>
      <dc:date>2018-10-02T23:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405283#M117149</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abcde_yudhbc "Sending message to queue" 
| dedup field1 
| stats count by field1
| map search="search index=ajhdahbd_hdhc $field1$ Successfully pushed to system |eval field1=\"$field1$\",count=$count$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Oct 2018 00:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405283#M117149</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2018-10-03T00:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405284#M117150</link>
      <description>&lt;P&gt;we are not able to see the expected output .we would like to see the result in three columns &lt;BR /&gt;
1.filed1 &lt;BR /&gt;
2.event of query1 which is related to field1 value &lt;BR /&gt;
3.event of query2 if it has filed1 value &lt;/P&gt;

&lt;P&gt;from the above query we have 300 field1 values but we see output for only 10 values . which means that every value of field1 is not passed to the second query.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 00:27:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405284#M117150</guid>
      <dc:creator>dsha</dc:creator>
      <dc:date>2018-10-03T00:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405285#M117151</link>
      <description>&lt;P&gt;According to the &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/7.0.5/SearchReference/Map"&gt;map command documentation&lt;/A&gt; the behavior you see is normal since the default maxsearches via map is 10. You can increase that manually, but I believe you will still not get the desired output, because the map command is not designed to append events to an existing set of results.&lt;BR /&gt;
One way to get the results you want is to change your base search to search both indexes for events you want then combining them with &lt;CODE&gt;stats&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;ex.&lt;BR /&gt;
index=abcde_yudhbc  "Sending message to queue" OR index=ajhdahbd_hdhc  "Successfully pushed to system " | stats count(eval(index=abcde-yudhbc)) as count by field&lt;/CODE&gt;&lt;BR /&gt;
Modify the stats command with whatever fields you need.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 03:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405285#M117151</guid>
      <dc:creator>vupham</dc:creator>
      <dc:date>2018-10-03T03:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405286#M117152</link>
      <description>&lt;P&gt;Thanks for the info vupham.  we are trying to achieve . with or with out using map we would like to achieve the below results.&lt;/P&gt;

&lt;P&gt;We have two different search queries with no unique fields and we would like to get the below info:&lt;/P&gt;

&lt;P&gt;1.we would like to search the value which we get in first query in the second query.&lt;/P&gt;

&lt;P&gt;2.if the value in first query is present in second query then we would like to print both the events &lt;/P&gt;

&lt;P&gt;we would like to see the result in three columns &lt;BR /&gt;
1.filed1 &lt;BR /&gt;
2.event of query1 which is related to field1 value &lt;BR /&gt;
3.event of query2 if it has filed1 value of first search query&lt;/P&gt;

&lt;P&gt;note : field1 value  we get only from first query . and in the secound query we need to search with the eah field1 value and if it matches then we need to print result in 3 columns which we have mentioned above.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 05:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405286#M117152</guid>
      <dc:creator>dsha</dc:creator>
      <dc:date>2018-10-03T05:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405287#M117153</link>
      <description>&lt;P&gt;When using map function please change maxsearches.&lt;/P&gt;

&lt;P&gt;In order to change the search sentence, the difficulty level changes with how to hold filed1.&lt;BR /&gt;
Does Query2(jhdahbd_hdhc) submit filed1? Can you search by keyword search only?&lt;/P&gt;

&lt;P&gt;search index=ajhdahbd_hdhc  $field1$&lt;BR /&gt;&lt;BR /&gt;
↓&lt;BR /&gt;
search index=ajhdahbd_hdhc  (field1="XX" OR  field1="YY" ･･･)   &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:25:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405287#M117153</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-09-29T21:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405288#M117154</link>
      <description>&lt;P&gt;field1 value is only present in search 1. we dont have same feildname in search 2. we would like the search the value of field1 in search query2 and get the events&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 16:13:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405288#M117154</guid>
      <dc:creator>dsha</dc:creator>
      <dc:date>2018-10-03T16:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405289#M117155</link>
      <description>&lt;P&gt;It is a query with poor efficiency because I do not know the condition.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ajhdahbd_hdhc "Successfully pushed to system" 
     [search index=abcde_yudhbc  "Sending message to queue" | dedup field1 |fields field1]
| rename _raw as rawText
| eval match_field=[search index=abcde_yudhbc  "Sending message to queue" | dedup field1 |stats values(field1) as query | eval query=mvjoin(query,",") | fields query ]
| eval match_field=split(match_field,",") 
| mvexpand match_field
| where like(rawText,"%"+match_field+"%")
| join type=left match_field [search index=abcde_yudhbc  "Sending message to queue" | dedup field1|rename field1 as match_field]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;※Because I am doing DEDUP, only one event is tied.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 01:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405289#M117155</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2018-10-04T01:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a value from one query in another second query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405290#M117156</link>
      <description>&lt;P&gt;Do not use map when it is not needed.  &lt;/P&gt;

&lt;P&gt;Is the position of the $field1$ value always the word directly before the phrase "Successfully pushed to system"?&lt;/P&gt;

&lt;P&gt;To verify, try this... make sure the capitalization and wordign in the rex is exactly the same as the record... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=foo2 "Successfully pushed to system")
| head 10 
| rex "\b(?\w+)\s+Successfully pushed to system"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the above properly extracts the field1 value, then run this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=foo1 "Sending message to queue") OR (index=foo2 "Successfully pushed to system")
| dedup field1 keepempty=true 
| rex "\b(?\w+)\s+Successfully pushed to system"
| eval unit=case(index=foo2,1)
| stats sum(unit) as count by field1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;... otherwise modify the rex until it is properly extracting the field1 value from the message, then proceed with the stats command&lt;/P&gt;

&lt;P&gt;The lesson here is, if a human can tell what the field1 value should be by looking at the layout of the event, then there is a way to build the field1 field, so you do that then use stats.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 20:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-search-a-value-from-one-query-in-another-second-query/m-p/405290#M117156</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-10-04T20:28:12Z</dc:date>
    </item>
  </channel>
</rss>

