<?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: Need help with an extract, combining fields, then finding users which have logged in but not logged out in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29037#M5816</link>
    <description>&lt;P&gt;This is a huge step in the right direction, but neither start (1) nor stop (2) are recognized fields without doing the extract. They're just a number after the 32nd comma. So when I put the extract back in, then it looks very similar to my initial query (but with the eval in teh outer search).&lt;/P&gt;

&lt;P&gt;sourcetype=NAPVPN | extract Extract_NAPVPN | search Acct_Status_Type="1" | eval uniqueID = ComputerName+Acct_Session_Id | search NOT [search sourcetype=NAPVPN Acct_Status_Type="2" | eval uniqueID = ComputerName+Acct_Session_Id | fields + uniqueID]&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 13:53:20 GMT</pubDate>
    <dc:creator>sanorthrup</dc:creator>
    <dc:date>2020-09-28T13:53:20Z</dc:date>
    <item>
      <title>Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29029#M5808</link>
      <description>&lt;P&gt;I need to find the log entries for users which have VPN'd in but not yet logged out. Each VPN session is supposed to have a unique "&lt;CODE&gt;Acct_Session_Id&lt;/CODE&gt;" but unfortunately we have duplicate &lt;CODE&gt;Acct_Session_Id&lt;/CODE&gt;'s because the logs come from multiple servers. So the &lt;CODE&gt;Acct_Session_Id&lt;/CODE&gt;'s are only unique to each ComputerName. My solution was to use an eval to combine &lt;CODE&gt;ComputerName+Acct_Session_Id&lt;/CODE&gt; to create a  new field with a truly unique ID. I've been calling this field UniqueID.&lt;/P&gt;

&lt;P&gt;I created a transform which lets me extract the fields I care about &lt;CODE&gt;Acct_Session_ID&lt;/CODE&gt;, &lt;CODE&gt;Acct_Status_Type&lt;/CODE&gt; and &lt;CODE&gt;ComputerName&lt;/CODE&gt;. I asked a similar question before for Cisco Secure ACS logs and got some great help and an answer. Now I'm trying to get the same data from IAS logs and the complexity of adding in the eval and the extract has got my head spinning in circles. Since it's got a subsearch, I'm not sure if I need to do the eval and extract for both.. Here's an example of what we use for Cisco Secure ACS:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="ssl_vpn" Acct_Status_Type = Start NOT [search sourcetype="ssl_vpn" Acct_Status_Type = Stop | fields + Acct_Session_Id | format maxresults=1000000]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's my attempt at getting the same data with an extract and an eval:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="1" NOT [search sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="2" | eval UniqueID = ComputerName + Acct_Session_Id | fields + UniqueId | format maxresults=1000000]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The results I'm getting are exactly the same as I get when I do it without the subsearch&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 15:52:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29029#M5808</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2013-05-09T15:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29030#M5809</link>
      <description>&lt;P&gt;Ok,I think I might be able to help.  So are you trying to pass your sub search back and use it as part of your base search to filter events?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 17:41:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29030#M5809</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2013-05-09T17:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29031#M5810</link>
      <description>&lt;P&gt;Well I think I understand. To return a subsearch and use the result in your base search to filter you want to use the &lt;STRONG&gt;return&lt;/STRONG&gt; command. The &lt;STRONG&gt;return&lt;/STRONG&gt; command is used to pass values up from a subsearch and remove the need for format or head. Take a look at my pervious post &lt;A href="http://splunk-base.splunk.com/answers/81983/subsearch-in-search-command-not-returning-results" target="_blank"&gt;subsearch-in-search-command-not-returning-results&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
sourcetype="ssl_vpn" Acct_Status_Type = Start NOT [search sourcetype="ssl_vpn" Acct_Status_Type = Stop | fields + Acct_Session_Id |&lt;STRONG&gt;return Acct_Session_Id&lt;/STRONG&gt;]&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;
&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;
sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="1" NOT [search sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="2" | eval UniqueID = ComputerName + Acct_Session_Id | fields + UniqueId | &lt;STRONG&gt;return UniqueId&lt;/STRONG&gt;]&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;You may have to play with limit.conf to increase the number of return values.  By default subsearches only return 100 and can not exceed 10500.  You might get around this by makeing the returned values into a single multvalued field.&lt;BR /&gt;
Hope this help or gets you started.  Dont forget to vote and accept answers that help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29031#M5810</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2020-09-28T13:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29032#M5811</link>
      <description>&lt;P&gt;Yes, exactly. Acct_Status_Type 1 = user login, Acct_Status_Type 2 = user logout. So I want to see all of the logs of the user that have logged in, but do not have a corresponding logout. What's supposed to be unique to their session is the Acct_Session_Id, but since we have multiple server there are dupe Acct_Session_Id's, so I'm trying to join ComputerName + Acct_Session_Id to make a unique session ID&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29032#M5811</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2020-09-28T13:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29033#M5812</link>
      <description>&lt;P&gt;I tried this, but it did not help. When I tried it on the search which is working perfectly (sourcetype=ssl_vpn) using the return command actually made it not work.&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2013 13:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29033#M5812</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2013-05-10T13:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29034#M5813</link>
      <description>&lt;P&gt;I'd try using the "&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;transaction&lt;/A&gt;" command.&lt;/P&gt;

&lt;P&gt;Pseudocode (you may have to tweak, especially the quotes around the Acct_Status_Type="1" fields):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="ssl_vpn" (Acct_Status_Type ="1" OR Acct_Status_Type ="2") | transaction ComputerName Acct_Session_Id maxspan=25h maxevents=2 keepevicted=true  startswith="Acct_Status_Type ="1"" endswith="Acct_Status_Type ="2" | where eventcount=1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you a list of connections that didn't exit, having only one event, the Acct_Status_Type="1" event.  The "keepevicted=true" option keeps the non-matching Acct_Status_Type="1" events in the result set. &lt;/P&gt;</description>
      <pubDate>Sat, 11 May 2013 23:38:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29034#M5813</guid>
      <dc:creator>Jon_Webster</dc:creator>
      <dc:date>2013-05-11T23:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29035#M5814</link>
      <description>&lt;P&gt;Basically your search says; &lt;/P&gt;

&lt;P&gt;'From sourcetype NAPVPN, gimme all events that are marked as "start", but not those that have the following uniqueIDs'&lt;/P&gt;

&lt;P&gt;The problem is that the uniqueID does not exist in the outer search, so the effect will be the same as skipping the subsearch altogether, as you noted.&lt;/P&gt;

&lt;P&gt;You'd probably have more luck if you structure the search like so (simplified below);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xxx type=start | eval uniqueID=A+B | search NOT [sourcetype=xxx type=stop | eval uniqueID=A+B | fields + uniqueID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2013 12:50:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29035#M5814</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-12T12:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29036#M5815</link>
      <description>&lt;P&gt;Oh, and you may want to investigate the possibility of creating a state table for VPN users, through the use of scheduled searches updating a lookup table. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/"&gt;http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2013 13:08:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29036#M5815</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-12T13:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29037#M5816</link>
      <description>&lt;P&gt;This is a huge step in the right direction, but neither start (1) nor stop (2) are recognized fields without doing the extract. They're just a number after the 32nd comma. So when I put the extract back in, then it looks very similar to my initial query (but with the eval in teh outer search).&lt;/P&gt;

&lt;P&gt;sourcetype=NAPVPN | extract Extract_NAPVPN | search Acct_Status_Type="1" | eval uniqueID = ComputerName+Acct_Session_Id | search NOT [search sourcetype=NAPVPN Acct_Status_Type="2" | eval uniqueID = ComputerName+Acct_Session_Id | fields + uniqueID]&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:53:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29037#M5816</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2020-09-28T13:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29038#M5817</link>
      <description>&lt;P&gt;Your logic is exactly right, but none of these fields exist until I load the extract. So I edited what you sent, but using this query I get more results than when I just search for logins. Any idea what I'm doing wrong?&lt;/P&gt;

&lt;P&gt;sourcetype="NAPVPN" | extract Extract_NAPVPN | search Acct_Status_Type ="1" OR Acct_Status_Type ="2" | transaction ComputerName Acct_Session_Id maxspan=48h maxevents=2 keepevicted=true startswith="Acct_Status_Type ="1"" endswith="Acct_Status_Type ="2"" | where eventcount=1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:53:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29038#M5817</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2020-09-28T13:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29039#M5818</link>
      <description>&lt;P&gt;yes - eval on inner and outer. what was the result?&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2013 20:51:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29039#M5818</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-13T20:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with an extract, combining fields, then finding users which have logged in but not logged out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29040#M5819</link>
      <description>&lt;P&gt;My unique ID was not actually unique. That's been fixed and this works great now. Thanks very much for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2013 16:58:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-an-extract-combining-fields-then-finding-users/m-p/29040#M5819</guid>
      <dc:creator>sanorthrup</dc:creator>
      <dc:date>2013-05-14T16:58:34Z</dc:date>
    </item>
  </channel>
</rss>

