<?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 display columns from 2 splunk queries based on a common column in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509669#M142463</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a query where I am passing one field from the output( outer query )to the another query&amp;nbsp; using subsearch based on field_1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=index_2 sourcetype=sourcetype_2 [search index=index_1 sourcetype=sourcetype_1 | fields field_1]|table field_1 field_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I could get the required results/events(field_1,field_2 ) from the outer query based on the common field field_1 with the innerquery&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NowI want some columns/fields from the subsearch or inner query along with the final result from outer query to be displayed. Please suggest&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 09:37:03 GMT</pubDate>
    <dc:creator>akkaraju</dc:creator>
    <dc:date>2020-07-17T09:37:03Z</dc:date>
    <item>
      <title>display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509669#M142463</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a query where I am passing one field from the output( outer query )to the another query&amp;nbsp; using subsearch based on field_1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=index_2 sourcetype=sourcetype_2 [search index=index_1 sourcetype=sourcetype_1 | fields field_1]|table field_1 field_2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I could get the required results/events(field_1,field_2 ) from the outer query based on the common field field_1 with the innerquery&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NowI want some columns/fields from the subsearch or inner query along with the final result from outer query to be displayed. Please suggest&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 09:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509669#M142463</guid>
      <dc:creator>akkaraju</dc:creator>
      <dc:date>2020-07-17T09:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509693#M142469</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223829"&gt;@akkaraju&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;let me understand: you have two queries with a common field.&lt;/P&gt;&lt;P&gt;You want as results some fields (some from search1 and some from search2) when the common field is present in both the searches, is it correct?&lt;/P&gt;&lt;P&gt;if this is your need you could run something like this:&lt;/P&gt;&lt;P&gt;if:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;field_1 is in both the searches,&lt;/LI&gt;&lt;LI&gt;field _2 is only in search1,&lt;/LI&gt;&lt;LI&gt;field_3 is only in search2.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;(index=index_2 sourcetype=sourcetype_2) OR (index=index_1 sourcetype=sourcetype_1)
| stats values(field_2) AS field_2 values(field_3) AS field_3 BY field_1
| table field_1 field_2 field_3&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 13:09:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509693#M142469</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-17T13:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509759#M142481</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;&lt;/P&gt;&lt;P&gt;I tried this. But I am not getting the common events based on the field 1.&lt;/P&gt;&lt;P&gt;the common field is present in both the searches all the time. I want the values where the common field value is same/equal in both searches. For example,&lt;/P&gt;&lt;P&gt;Search 1 gives 3 columns&lt;/P&gt;&lt;P&gt;C1 C2 C3&lt;/P&gt;&lt;P&gt;A.&amp;nbsp; &amp;nbsp;a&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;B&amp;nbsp; &amp;nbsp; b&amp;nbsp; &amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;C&amp;nbsp; &amp;nbsp;c&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;I need to search where a C3 has the values 1,2 ,3 in another index and source. For each value in search 1 I want corresponding values in search 2 based on the common filed value. That's why I used sub search, which is giving the output.&lt;/P&gt;&lt;P&gt;C1 C2&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; &amp;nbsp; &amp;nbsp;x&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; &amp;nbsp; &amp;nbsp;z&lt;/P&gt;&lt;P&gt;But&amp;nbsp; I want&lt;/P&gt;&lt;P&gt;C1 C2 C3&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; &amp;nbsp; &amp;nbsp;x.&amp;nbsp; &amp;nbsp; A&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; &amp;nbsp; &amp;nbsp;y.&amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; &amp;nbsp; &amp;nbsp;z.&amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;/P&gt;&lt;P&gt;based on a common column, I want values from the search2 and also some corresponding columns in search 1.Hope I am clear. Think of 2 searches with the same column called IdNumber. I want the address of all the persons obtained in search 1(Id,name) from search 2. So I get&amp;nbsp; a table of Id,Address. But I want a table with Id name, address&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 17:20:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509759#M142481</guid>
      <dc:creator>akkaraju</dc:creator>
      <dc:date>2020-07-17T17:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509837#M142518</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223829"&gt;@akkaraju&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;you could try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=index_2 sourcetype=sourcetype_2) OR (index=index_1 sourcetype=sourcetype_1)
| eval key=coalesce(C3,C1)
| stats values(C2) AS C2 values(C3) AS C3 BY key
| rename key AS C1
| table C1 C2 C3&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 15:04:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509837#M142518</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-18T15:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509860#M142528</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;&lt;/P&gt;&lt;P&gt;Thank you for your replies. But this seems to be not working. FYI you said coalsce c1,c3.. but the names are same (ID) I feel the OR condition you are mentioning is not right. I need a subsearch approach where for each value of&amp;nbsp; ID column in search 1 ,I should get a corresponding row in search 2 (every event in search 2 should&amp;nbsp; have the same value of ID ). Like I get 136 results in search 1, I should get the corresponding 136 events in search 2 with the common value ID.&lt;/P&gt;&lt;P&gt;This is my query&lt;/P&gt;&lt;DIV&gt;index=index2 name=name2 [search index=index1 name=name1 | fields ID]|table ID , Address&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ID is the common column&lt;/DIV&gt;&lt;DIV&gt;Search 2 has the columns&amp;nbsp; ID and Address, but search 1 has ID and Name... But I am getting only the columns from search 2. I want ID ,name and address in a table. I feel I should be able to append or join the two searches. Please help&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Jul 2020 18:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509860#M142528</guid>
      <dc:creator>akkaraju</dc:creator>
      <dc:date>2020-07-18T18:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509878#M142539</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223829"&gt;@akkaraju&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;If you have few events you can use the join command that's the solution you are searching:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index2 name=name2
| join ID [search index=index1 name=name1 ]
| table ID name address&lt;/LI-CODE&gt;&lt;P&gt;but I usually don't use it because it has the limit of 50,000 results in subsearch, it's slower than the other and it uses more resources (CPU), is this acceptable for you?&lt;/P&gt;&lt;P&gt;I hint to explore still for some minutes my approach:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=index2 name=name2) OR (index=index1 name=name1)
| stats values(name) AS name values(address) AS address BY ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 05:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/509878#M142539</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-07-19T05:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: display columns from 2 splunk queries based on a common column</title>
      <link>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/510196#M142764</link>
      <description>&lt;P&gt;Currently this is working for me. but its slow because of append&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"query 2" | table ID, Address| eval From=1 | append [search "query 1"| table ID Name | eval From=2 ] | stats values(*) as * by ID | where mvcount(From)=2 |table ID Name Address&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;, thanks for your responses.&lt;/P&gt;&lt;P&gt;Your answer is giving me all the results but not the results where ID is equal only&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 09:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/display-columns-from-2-splunk-queries-based-on-a-common-column/m-p/510196#M142764</guid>
      <dc:creator>akkaraju</dc:creator>
      <dc:date>2020-07-21T09:50:42Z</dc:date>
    </item>
  </channel>
</rss>

