<?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: Count Open Sessions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261236#M78397</link>
    <description>&lt;P&gt;If you trust that AUT22670 or AUT24414 without a corresponding AUT22673  represents a logged in user, use &lt;STRONG&gt;dedup&lt;/STRONG&gt; to capture only the latest event for each user. Thus if a user has the log off event, you know their session is closed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_source (MsgId=AUT22670 OR MsgId=AUT24414 OR  MsgId=AUT22673) | dedup User | eval SESSIONS_STATUS=if(MsgId==AUT22673,"CLOSED SESSION","OPEN SESSION") | table User SESSIONS_STATUS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Dedup"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Dedup&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2015 14:34:24 GMT</pubDate>
    <dc:creator>jplumsdaine22</dc:creator>
    <dc:date>2015-12-03T14:34:24Z</dc:date>
    <item>
      <title>Count Open Sessions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261235#M78396</link>
      <description>&lt;P&gt;Hi all. I'm trying to make a gauge that counts the amount of logged on users. Stuck on figuring out how to classify a session as "Open". Once I do this I'd just count the amount of "OPEN SESSIONS"s. (Doing it this way incase the boss prefers a table.)&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;If MsgId is AUT22670 or AUT24414 the event represent a login. If the MsgId is AUT22673 then the event represents a logout.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Example Events:&lt;BR /&gt;
User, Date, Time, MsgId&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    my search..
    | eval ID=User | eval LoginDate=Date | eval LoginTime=Time
    | eval SESSIONS_STATUS = if((match(User,(?i)ID)) AND (NOT MsgId=AUT22673),"OPEN SESSION","CLOSED SESSION")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Its not working the way I want but am I headed in the right direction?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 14:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261235#M78396</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-12-03T14:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Count Open Sessions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261236#M78397</link>
      <description>&lt;P&gt;If you trust that AUT22670 or AUT24414 without a corresponding AUT22673  represents a logged in user, use &lt;STRONG&gt;dedup&lt;/STRONG&gt; to capture only the latest event for each user. Thus if a user has the log off event, you know their session is closed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=my_source (MsgId=AUT22670 OR MsgId=AUT24414 OR  MsgId=AUT22673) | dedup User | eval SESSIONS_STATUS=if(MsgId==AUT22673,"CLOSED SESSION","OPEN SESSION") | table User SESSIONS_STATUS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Dedup"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/SearchReference/Dedup&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 14:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261236#M78397</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2015-12-03T14:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Count Open Sessions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261237#M78398</link>
      <description>&lt;P&gt;Your &lt;CODE&gt;match&lt;/CODE&gt; command is filtering out all Users except those called "ID", "Id, "id", or "iD" - probably not what you want.&lt;/P&gt;

&lt;P&gt;Here is a slightly different approach that may help.  Use the &lt;CODE&gt;dedup&lt;/CODE&gt; command to get the most recent event for each user then filter out the logout events.  What's left will be a list of open sessions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search | dedup User | where NOT MsgId==AUT22673 | eval LoginTime=_time | table User LoginTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Dec 2015 14:46:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261237#M78398</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-12-03T14:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Count Open Sessions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261238#M78399</link>
      <description>&lt;P&gt;This works nicely. Yeah sometimes I get confused and try to attack things on Splunk as I would with a perl script. &lt;/P&gt;

&lt;P&gt;Someone showed me this too.&lt;BR /&gt;
    my search...&lt;BR /&gt;
    | transaction User startswith="MsgId=AUT22670 OR MsgId=AUT24414" endswith="MsgId=AUT22673" keeporphans=true &lt;BR /&gt;
    | search linecount=1&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 15:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261238#M78399</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-12-03T15:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count Open Sessions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261239#M78400</link>
      <description>&lt;P&gt;Thanks appreciate it!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 15:31:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-Open-Sessions/m-p/261239#M78400</guid>
      <dc:creator>jsven7</dc:creator>
      <dc:date>2015-12-03T15:31:38Z</dc:date>
    </item>
  </channel>
</rss>

