<?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 to get an output for two different searches using join? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264068#M79259</link>
    <description>&lt;P&gt;For a join to work, both result set should return a common column and you need to specify the column in join command  (see &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;Join&lt;/A&gt; command's document for more details). So your query if using join should be like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sftp USER=gradydftsftpdata SESSION_ID=* | table USER, SESSION_ID,USER_IP,date_hour | dedup SESSION_ID,USER_IP| join type=left SESSION_ID [search index=sftp SESSION_ID=* date_hour=* ACTION != session | table SESSION_ID FILE_NAME, _time, USER_IP, ACTION] | table FILE_NAME,USER, SESSION_ID,USER_IP,date_hour,_time,ACTION
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Jan 2017 15:18:17 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-01-30T15:18:17Z</dc:date>
    <item>
      <title>How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264067#M79258</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;Search 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sftp" USER=gradydftsftpdata | table USER, SESSION_ID,USER_IP,date_hour | dedup SESSION_ID,USER_IP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with this search I'm able to get USER,SESSION_ID,USER_IP,date_hour &lt;/P&gt;

&lt;P&gt;Search 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sftp" SESSION_ID=9666 date_hour=3 ACTION != session | table FILE_NAME, _time, USER_IP, ACTION.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with this search i'm able to get the session_id of the a particular session with file_name,_time , user_ip, ACTION.&lt;/P&gt;

&lt;P&gt;What i'm trying to get is File_NAME,USER,SESSION_ID,date_hour,USER_IP,ACTION and the search that i'm using is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sftp USER=gradydftsftpdata SESSION_ID=*  | join sftp[search index=sftp  SESSION_ID=* date_hour=* ACTION != session | table FILE_NAME, _time, USER_IP, ACTION] |  table FILE_NAME,USER, SESSION_ID,USER_IP,date_hour,_time,ACTION | dedup SESSION_ID,USER_IP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this the correct search that i'm using to get output??&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:37:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264067#M79258</guid>
      <dc:creator>sujith0311</dc:creator>
      <dc:date>2020-09-29T12:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264068#M79259</link>
      <description>&lt;P&gt;For a join to work, both result set should return a common column and you need to specify the column in join command  (see &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;Join&lt;/A&gt; command's document for more details). So your query if using join should be like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sftp USER=gradydftsftpdata SESSION_ID=* | table USER, SESSION_ID,USER_IP,date_hour | dedup SESSION_ID,USER_IP| join type=left SESSION_ID [search index=sftp SESSION_ID=* date_hour=* ACTION != session | table SESSION_ID FILE_NAME, _time, USER_IP, ACTION] | table FILE_NAME,USER, SESSION_ID,USER_IP,date_hour,_time,ACTION
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jan 2017 15:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264068#M79259</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-30T15:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264069#M79260</link>
      <description>&lt;P&gt;It will depend upon what your events look like. For example, do all your events contain a common field? Or do you have different event types within the index. It would help if you could post an example &lt;/P&gt;

&lt;P&gt;Here is a handy flowchart on when to use join that may be of use: &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 15:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264069#M79260</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2017-01-30T15:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264070#M79261</link>
      <description>&lt;P&gt;It seems like you are overcomplicating things.  You are searching in the first search and specifying your user, and in the second you are specifying session ID and hour.  &lt;/P&gt;

&lt;P&gt;If what you are trying to do makes any sense, then you must be trying to find two different related records in the same hour, and query 1 is getting the session record while query 2 gets the non-session record.  If that is true, though, then you need to be specifying ACTION = session in the first query.&lt;/P&gt;

&lt;P&gt;The problem is that you need all common fields for a unique join.&lt;/P&gt;

&lt;P&gt;Can you please show an example of the results of each query?  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sftp" USER=gradydftsftpdata 
| table USER, SESSION_ID,USER_IP,date_hour 
| dedup SESSION_ID,USER_IP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, to properly join with that, you'll need to keep at least the SESSION_ID and the date_hour for the second query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="sftp" SESSION_ID=9666 date_hour=3 ACTION != session 
| table FILE_NAME, _time, SESSION_ID,  date_hour, USER_IP, ACTION
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Not knowing more about your data, I can't tell you which of the above queries should be the "left" part of the join. &lt;/P&gt;

&lt;P&gt;Can you give more information about what you think each of your queries is doing?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:40:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264070#M79261</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T12:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264071#M79262</link>
      <description>&lt;P&gt;USER               SESSION_ID  USER_IP date_hour&lt;BR /&gt;
gradydftsftpdata    20716                           10&lt;BR /&gt;
gradydftsftpdata    15931                            9&lt;BR /&gt;
gradydftsftpdata    11034                            8&lt;BR /&gt;
gradydftsftpdata    6597                             7&lt;BR /&gt;
gradydftsftpdata    2127                            6&lt;BR /&gt;
gradydftsftpdata    28354                               5&lt;BR /&gt;
gradydftsftpdata    23974                            4&lt;BR /&gt;
gradydftsftpdata    19498                            3&lt;BR /&gt;
gradydftsftpdata    14957                               2&lt;/P&gt;

&lt;P&gt;This is the result for the first query&lt;/P&gt;

&lt;P&gt;FILE_NAME                                                                       _time                    USER_IP    ACTION&lt;BR /&gt;
/datafeed/EL/xyz_EL_201705136.txt             2017-01-27 03:15:04                                  close&lt;BR /&gt;
/datafeed/EL/xyz_EL_201705136.txt                    2017-01-27 03:15:04                                    open&lt;/P&gt;

&lt;P&gt;This is the output for the second query.&lt;/P&gt;

&lt;P&gt;when i use this query &lt;/P&gt;

&lt;P&gt;index=sftp USER=gradydftsftpdata SESSION_ID=*  | join sftp[search index=sftp  SESSION_ID=* date_hour=* ACTION != session | table FILE_NAME, _time, USER_IP, ACTION] |  table FILE_NAME,USER, SESSION_ID,USER_IP,date_hour,_time,ACTION | dedup SESSION_ID,USER_IP&lt;/P&gt;

&lt;P&gt;I get the output as&lt;/P&gt;

&lt;P&gt;FILE_NAME                                          USER SESSION_ID  USER_IP    date_hour    _time             ACTION&lt;BR /&gt;
/datafeed/                                     gradydftsftpdata 20716                       10   2017-01-30 10:15:05    forced&lt;BR /&gt;
/datafeed/                              gradydftsftpdata    15931                            9  2017-01-30 09:15:03 forced&lt;/P&gt;

&lt;P&gt;What result i'm looking for is , when we enter the above query I need to get the ACTION as closed and open for particular FILE_NAME as we got in query 2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264071#M79262</guid>
      <dc:creator>sujith0311</dc:creator>
      <dc:date>2020-09-29T12:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264072#M79263</link>
      <description>&lt;P&gt;Hi Somesoni2,&lt;/P&gt;

&lt;P&gt;I got that query executed . But [search index=sftp SESSION_ID=* date_hour=* ACTION != session. I edited ACTION !=session to ACTION = open or close i mean one at a time and i'm able to get the exact output what i'm expecting for. But where can i initialize if i want to see open and close together in that query.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:37:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264072#M79263</guid>
      <dc:creator>sujith0311</dc:creator>
      <dc:date>2020-09-29T12:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264073#M79264</link>
      <description>&lt;P&gt;Try like this &lt;CODE&gt;ACTION="open" OR ACTION="close"&lt;/CODE&gt;, instead of &lt;CODE&gt;ACTION != session&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 17:16:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264073#M79264</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-30T17:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264074#M79265</link>
      <description>&lt;P&gt;when i replace it with the above one it displays all the closed content. I think the files which having the filename need to be verified.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 17:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264074#M79265</guid>
      <dc:creator>sujith0311</dc:creator>
      <dc:date>2017-01-30T17:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264075#M79266</link>
      <description>&lt;P&gt;The thing is the join is doing one-on-one match with your session logs. So, even if you're using &lt;CODE&gt;ACTION="open" OR ACTION="close"&lt;/CODE&gt;, the latest records, which I assume is the one with ACTION=close, is getting returned. If you want data from both ACTION to be returned, try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sftp USER=gradydftsftpdata SESSION_ID=* | table USER, SESSION_ID,USER_IP,date_hour | dedup SESSION_ID,USER_IP| join type=left max=2 SESSION_ID [search index=sftp SESSION_ID=* date_hour=* ACTION="open" OR ACTION="close" | table SESSION_ID FILE_NAME, _time, USER_IP, ACTION] | table FILE_NAME,USER, SESSION_ID,USER_IP,date_hour,_time,ACTION
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jan 2017 17:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264075#M79266</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-30T17:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264076#M79267</link>
      <description>&lt;P&gt;It works somesoni. Can I know what's the best practice for splunk quries. Can you suggest me any kind of documentation or something like that&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 17:55:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264076#M79267</guid>
      <dc:creator>sujith0311</dc:creator>
      <dc:date>2017-01-30T17:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get an output for two different searches using join?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264077#M79268</link>
      <description>&lt;P&gt;I would read these&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Writebettersearches"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Writebettersearches&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://wiki.splunk.com/Things_I_wish_I_knew_then"&gt;https://wiki.splunk.com/Things_I_wish_I_knew_then&lt;/A&gt;  (Searches UI section) &lt;BR /&gt;
&lt;A href="https://wiki.splunk.com/Community:More_best_practices_and_processes"&gt;https://wiki.splunk.com/Community:More_best_practices_and_processes&lt;/A&gt; (searching and reporting section)&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2017 18:08:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-an-output-for-two-different-searches-using-join/m-p/264077#M79268</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-30T18:08:59Z</dc:date>
    </item>
  </channel>
</rss>

