<?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: Linked searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40394#M9308</link>
    <description>&lt;P&gt;You could also use &lt;CODE&gt;transaction&lt;/CODE&gt;. See my updated answer.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Aug 2012 11:15:50 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2012-08-21T11:15:50Z</dc:date>
    <item>
      <title>Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40388#M9302</link>
      <description>&lt;P&gt;I index 2 log files which have a common ID field in them. I'd like to search against log file 1, get a series of IDs which match my search term and then use those IDs to find info from log file 2, eg&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=Log1 error="some error message" | source=Log2 ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the above, the search to the left of the pip finds 1 or more results. On the right of the pipe we search for all events which have the ID from the first part of the search.&lt;/P&gt;

&lt;P&gt;Seems like it should be easy but I'm having a "can't see the wood for the trees" moment and can't work it out.&lt;/P&gt;

&lt;P&gt;thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 10:33:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40388#M9302</guid>
      <dc:creator>Bulluk</dc:creator>
      <dc:date>2012-08-21T10:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40389#M9303</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;source=log1 error="ERROR" | join ID [search source=Log2]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will do a SQL like join on the ID field.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 10:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40389#M9303</guid>
      <dc:creator>johandk</dc:creator>
      <dc:date>2012-08-21T10:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40390#M9304</link>
      <description>&lt;P&gt;As I understand your requirement I think your best option might be to use a regular subsearch (&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/User/HowSubsearchesWork"&gt;http://docs.splunk.com/Documentation/Splunk/latest/User/HowSubsearchesWork&lt;/A&gt; ).&lt;/P&gt;

&lt;P&gt;Step-by-step: " I'd like to search against log file 1, get a series of IDs which match my search term"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=Log1 error="some error message"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;"and then use those IDs to find info from log file 2"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=Log2 [search source=Log1 error="some error message" | fields ID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: If you want the actual events from both sources, you could either use &lt;CODE&gt;join&lt;/CODE&gt; as has been suggested, or &lt;CODE&gt;transaction&lt;/CODE&gt; that will create a new event (a transaction) that combines all events having the same ID.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(source=Log1 error="some error message") OR (source=Log2) | transaction ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2012 10:58:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40390#M9304</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-21T10:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40391#M9305</link>
      <description>&lt;P&gt;This looks close but I'm getting odd results&lt;/P&gt;

&lt;P&gt;source=log1 error="ERROR" returns over 100 results&lt;/P&gt;

&lt;P&gt;source=log1 error="ERROR" | join ID [search source=Log2] only returns 1 result despite there being a 1 to 1 relationship with the ID. &lt;/P&gt;

&lt;P&gt;I shall play a bit more to see if I can work out what I'm doing wrong&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 11:07:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40391#M9305</guid>
      <dc:creator>Bulluk</dc:creator>
      <dc:date>2012-08-21T11:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40392#M9306</link>
      <description>&lt;P&gt;Log1 contains the error message and the ID.&lt;BR /&gt;
Log2 contains the ID and some other info I'm interested in. In a scripting language I'd pass the result of the first query into an array then iterate around it to find the info I want in Log2 ie&lt;/P&gt;

&lt;P&gt;$IDs = 1,2,3,4&lt;/P&gt;

&lt;P&gt;foreach ($ID in $IDs)&lt;BR /&gt;
{&lt;BR /&gt;
select $info1, $info2&lt;BR /&gt;
where $IDfield = $ID&lt;BR /&gt;
}&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 11:10:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40392#M9306</guid>
      <dc:creator>Bulluk</dc:creator>
      <dc:date>2012-08-21T11:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40393#M9307</link>
      <description>&lt;P&gt;OK, so you want not just the ID from log1, but also the actual event? In that case the requirement will indeed be a bit different, as the subsearch would essentially return something like &lt;CODE&gt;((id="id1") OR (id="id2") OR ... )&lt;/CODE&gt; to the outer search.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 11:13:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40393#M9307</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-21T11:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40394#M9308</link>
      <description>&lt;P&gt;You could also use &lt;CODE&gt;transaction&lt;/CODE&gt;. See my updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 11:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40394#M9308</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-08-21T11:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40395#M9309</link>
      <description>&lt;P&gt;source=Log2 [search source=Log1 error="some error message" | fields ID]&lt;/P&gt;

&lt;P&gt;This is the one that nailed it for me. Thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 13:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40395#M9309</guid>
      <dc:creator>Bulluk</dc:creator>
      <dc:date>2012-08-21T13:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Linked searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40396#M9310</link>
      <description>&lt;P&gt;I ended up using Ayn's solution below but I think the join approach would have worked if I'd spent time with it. Thanks for your help&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 13:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Linked-searches/m-p/40396#M9310</guid>
      <dc:creator>Bulluk</dc:creator>
      <dc:date>2012-08-21T13:13:37Z</dc:date>
    </item>
  </channel>
</rss>

