<?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 Splunk - Join two queries from same index and eventtype in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367202#M162064</link>
    <description>&lt;P&gt;I have the following two events from the same index (VPN). I've been unable to try and join two searches to get a table of users logged in to VPN, srcip, and sessions (if logged out 4911 field). I'm able to pull out this infor if I search individually but unable to combine. Thanks for the help.&lt;/P&gt;

&lt;P&gt;259 &amp;lt;166&amp;gt;1 2018-03-21T10:13:45-04:00 abc.defg.net PulseSecure: - - - 2018-03-21 10:13:45 - ive - [12.34.56.78] DHI\john(VPN)[VPN] - Login succeeded for FHI\john/VPN (session:be1c9211) from 12.34.56.78 with Open AnyConnect VPN Agent v7.08&lt;/P&gt;

&lt;P&gt;276 &amp;lt;166&amp;gt;1 2018-03-21T11:35:39-04:00 abc.defg.net PulseSecure: - - - 2018-03-21 11:35:39 - ive - [12.34.56.78] DHI\john(VPN)[VPN] - Closed connection to TUN-VPN port 443 after 4911 seconds, with 2171883 bytes read (in 6 chunks) and 90236 bytes written (in 8 chunks)&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 22:39:04 GMT</pubDate>
    <dc:creator>mikeyemane</dc:creator>
    <dc:date>2018-03-21T22:39:04Z</dc:date>
    <item>
      <title>Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367202#M162064</link>
      <description>&lt;P&gt;I have the following two events from the same index (VPN). I've been unable to try and join two searches to get a table of users logged in to VPN, srcip, and sessions (if logged out 4911 field). I'm able to pull out this infor if I search individually but unable to combine. Thanks for the help.&lt;/P&gt;

&lt;P&gt;259 &amp;lt;166&amp;gt;1 2018-03-21T10:13:45-04:00 abc.defg.net PulseSecure: - - - 2018-03-21 10:13:45 - ive - [12.34.56.78] DHI\john(VPN)[VPN] - Login succeeded for FHI\john/VPN (session:be1c9211) from 12.34.56.78 with Open AnyConnect VPN Agent v7.08&lt;/P&gt;

&lt;P&gt;276 &amp;lt;166&amp;gt;1 2018-03-21T11:35:39-04:00 abc.defg.net PulseSecure: - - - 2018-03-21 11:35:39 - ive - [12.34.56.78] DHI\john(VPN)[VPN] - Closed connection to TUN-VPN port 443 after 4911 seconds, with 2171883 bytes read (in 6 chunks) and 90236 bytes written (in 8 chunks)&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 22:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367202#M162064</guid>
      <dc:creator>mikeyemane</dc:creator>
      <dc:date>2018-03-21T22:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367203#M162065</link>
      <description>&lt;P&gt;What are your two searches that you want to combine?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 01:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367203#M162065</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-03-22T01:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367204#M162066</link>
      <description>&lt;P&gt;Thanks for help Rich. First event shows userid, time session started, and srcip. Second event shows the same, except time session ended and session duration (4911 seconds). I want to generate a table of userid, srcip, time session started, time session ended, and duration. Here are the two searches that kind of get me what I'm looking for:&lt;/P&gt;

&lt;P&gt;index=juniper-mag host=abc.defg.net _raw=&lt;EM&gt;"Login succeeded"&lt;/EM&gt; | eval fields=split(_raw, " ") | eval user=mvindex(fields,14) | eval srcip=mvindex(fields, 13) | table _time user srcip&lt;/P&gt;

&lt;P&gt;index=juniper-mag host=abc.defg.net _raw=&lt;EM&gt;"Closed connection"&lt;/EM&gt; | eval fields=split(_raw, " ") | eval duration=mvindex(fields,23) | table _time user duration&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367204#M162066</guid>
      <dc:creator>mikeyemane</dc:creator>
      <dc:date>2020-09-29T18:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367205#M162067</link>
      <description>&lt;P&gt;please try this.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=juniper-mag host=abc.defg.net "Login succeeded" OR "Closed connection" | eval fields=split(_raw, " ") | eval user=mvindex(fields,14) | eval duration=mvindex(fields,23)| eval srcip=mvindex(fields, 13) | stats latest(_time) as time latest(duration) as duration by user,srcip | convert ctime(time) as time&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 02:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367205#M162067</guid>
      <dc:creator>kyaparla</dc:creator>
      <dc:date>2018-03-22T02:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367206#M162068</link>
      <description>&lt;P&gt;Didn't even notice they were the same index and host.  This is much better.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 02:54:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367206#M162068</guid>
      <dc:creator>BearMormont</dc:creator>
      <dc:date>2018-03-22T02:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367207#M162069</link>
      <description>&lt;P&gt;Always worth to read this answer &lt;A href="https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 02:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367207#M162069</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-03-22T02:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367208#M162070</link>
      <description>&lt;P&gt;If I interpret your events correctly, this query should do the job.  The three &lt;CODE&gt;rex&lt;/CODE&gt; commands extract the desired fields then the &lt;CODE&gt;stats&lt;/CODE&gt; command puts the events together by userid.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=juniper-mag host=abc.defg.net ("Login succeeded" OR "Closed connection") | rex "\]\s(?&amp;lt;userid&amp;gt;[^\(]+)" | rex "Login succeeded.*from (?&amp;lt;srcip&amp;gt;[^\s]+)" | rex "after\s(?&amp;lt;duration&amp;gt;\d+)\sseconds" | stats earliest(_time) as sessionStart latest(_time) as sessionEnded values(duration) as duration values(srcip) as srcip by userid | fieldformat sessionStart=strftime(sessionStart,"%Y-%m-%dT%H:%M:%S%:z") | fieldformat sessionEnded=strftime(sessionEnded,"%Y-%m-%dT%H:%M:%S%:z")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Mar 2018 03:17:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367208#M162070</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-03-22T03:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Join two queries from same index and eventtype</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367209#M162071</link>
      <description>&lt;P&gt;Thank you. This gave me what I was looking for. Response from kyaparla was also good. Thank you both.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 03:48:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-Join-two-queries-from-same-index-and-eventtype/m-p/367209#M162071</guid>
      <dc:creator>mikeyemane</dc:creator>
      <dc:date>2018-03-22T03:48:32Z</dc:date>
    </item>
  </channel>
</rss>

