<?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 search for the &amp;quot;Log In&amp;quot; and &amp;quot;Log Out&amp;quot; event when they appear to have the same pattern in my logs? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334513#M99421</link>
    <description>&lt;P&gt;Hi everybody,&lt;BR /&gt;
Thanks for your answers.&lt;BR /&gt;
The partner of my company send me a new log file with more details.....&lt;BR /&gt;
i do apologise for the inconvenience。 本当にごめんなさい！！！&lt;BR /&gt;
On the new log file , I have an event to define the beginning :&lt;BR /&gt;
LOG IN -- &amp;gt; Mar 1 21:45:41 XDSauth: 1488433541 |ConnectorSession.setNextServiceName     |next service name =  X&lt;BR /&gt;
                    Mar 1 21:45:41 XDSauth: 1488433541 |ServiceHdlr.serviceTerminated |next service = X&lt;BR /&gt;
LOG OUT --&amp;gt; Mar 1 21:47:05 XDSauth: 1488433625 |ServiceHdlr.serviceTerminated |next service = X &lt;BR /&gt;
Where X is the user name.&lt;/P&gt;

&lt;P&gt;But the problem is : ServiceHdlr.serviceTerminated&lt;BR /&gt;
I have this event twice.&lt;BR /&gt;
One after ConnectorSession.setNextServiceName and the next is to define the end of connection.&lt;/P&gt;

&lt;P&gt;If I use &lt;BR /&gt;
startswith="ConnectorSession.setNextServiceName" endswith="ServiceHdlr.serviceTerminated"&lt;BR /&gt;
The result is :&lt;BR /&gt;
2017-03-02 14:45:39.000  ConnectorSession.setNextServiceName&lt;BR /&gt;
2017-03-02 14:45:41.000  ServiceHdlr.serviceTerminated&lt;/P&gt;

&lt;P&gt;But the end of the connection is : 2017-03-02 14:46:13.000 &lt;/P&gt;

&lt;P&gt;With this new log file, that's more easier to define the beginning but I have still a problem to define the End.&lt;/P&gt;

&lt;P&gt;Maybe create a condition to select the second event  "ServiceHdlr.serviceTerminated" ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Laurent&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2017 02:22:04 GMT</pubDate>
    <dc:creator>LNebout</dc:creator>
    <dc:date>2017-03-03T02:22:04Z</dc:date>
    <item>
      <title>How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334507#M99415</link>
      <description>&lt;P&gt;Hi everybody, &lt;BR /&gt;
I have a problem with a log file to search the log In and log Out event.&lt;BR /&gt;
pattern :&lt;/P&gt;

&lt;P&gt;Line 2   --&amp;gt;   Mar  1 21:47:05 XDSauth: 1488433625 |ServiceHdlr.serviceTerminated           |next service = X &lt;BR /&gt;
Line 1   --&amp;gt;   Mar  1 21:45:41 XDSauth: 1488433541 |ServiceHdlr.serviceTerminated           |next service = X &lt;/P&gt;

&lt;P&gt;( XDSauth:  --&amp;gt; Epoch Time , I converted the format : | fieldformat Epoch_Time = strftime(Epoch_Time, "%F %T.%3N") )&lt;/P&gt;

&lt;P&gt;I search a solution to tag the Line 1 --&amp;gt; Log IN and Line 2 --&amp;gt; Log OUT &lt;/P&gt;

&lt;P&gt;If anybody has an idea or advice , I'm more than interested ^_^&lt;BR /&gt;
Thanks, &lt;BR /&gt;
Laurent&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334507#M99415</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2020-09-29T13:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334508#M99416</link>
      <description>&lt;P&gt;Are you sure that these are the correct log texts?  They appear to be perfectly identical with nothing to distinguish a login from a logout.  How is this distinguished?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 00:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334508#M99416</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-03T00:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334509#M99417</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt; ,&lt;/P&gt;

&lt;P&gt;Yes , this is the good logs.&lt;BR /&gt;
That's the problem. lol&lt;BR /&gt;
The only difference is the time. The module where this data drawn from war created by a partner of my company.&lt;BR /&gt;
And they send me a log file for example. I have only this lines with the user name to define the LOG IN and LOG OUT&lt;/P&gt;

&lt;P&gt;I try this to isolate :&lt;BR /&gt;
sourcetype=XDSauth | fieldformat Epoch_Time = strftime(Epoch_Time, "%F %T.%3N") | transaction User maxevents=2 startswith="ServiceHdlr.serviceTerminated" endswith="ServiceHdlr.serviceTerminated" | eval t=Epoch_Time+duration | convert timeformat="%y-%m-%d %H:%M:%S" ctime(t) AS TIME | table User,TIME&lt;/P&gt;

&lt;P&gt;Result: &lt;BR /&gt;
User name                               Time&lt;BR /&gt;
007                                              17-03-02 14:47:05&lt;BR /&gt;
007                                              17-03-02 14:45:41&lt;/P&gt;

&lt;P&gt;Best regards&lt;BR /&gt;
Laurent&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334509#M99417</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2020-09-29T13:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334510#M99418</link>
      <description>&lt;P&gt;It is highly unlikely that these events are actually a login and logout without additional data.&lt;/P&gt;

&lt;P&gt;There is no userid or other data on what is being logged into or out of, how, by whom.&lt;/P&gt;

&lt;P&gt;What is the form of the data in the area marked  X?  What is the actual format of the _raw data?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 00:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334510#M99418</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-03T00:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334511#M99419</link>
      <description>&lt;P&gt;@DalJeanis&lt;BR /&gt;
Hello Daljeanis,&lt;BR /&gt;
Sorry , I forgot an information : &lt;BR /&gt;
Mar 1 21:45:41 XDSauth: 1488433541 |ServiceHdlr.serviceTerminated |next service = X&lt;/P&gt;

&lt;P&gt;next service = X --&amp;gt; user name&lt;/P&gt;

&lt;P&gt;Log format --&amp;gt; raw data ( linux log)&lt;/P&gt;

&lt;P&gt;A good challenge lol&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Laurent&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 00:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334511#M99419</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2017-03-03T00:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334512#M99420</link>
      <description>&lt;P&gt;So, there is literally no difference between login and logout records.  That is a design or code error at the source, your company's partner.  The logon records should say something like "ServiceHdlr.serviceStarted"&lt;/P&gt;

&lt;P&gt;1) get rid of the startswith and endswith.  Since the same wording is on both of them, you're only confusing splunk.&lt;/P&gt;

&lt;P&gt;2) determine what a reasonable duration would be for a session, and set that as your maxspan value.  leave maxpause as default (forever).  set keeporphans=true.&lt;/P&gt;

&lt;P&gt;So, it looks like this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   | transaction User maxevents=2 maxspan=2h keeporphans=T
   | eval StartTime=_time, eval EndTime=_time+duration
   | table User, StartTime, EndTime, duration
   | (reformat Times and duration how you want them)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 01:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334512#M99420</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-03T01:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334513#M99421</link>
      <description>&lt;P&gt;Hi everybody,&lt;BR /&gt;
Thanks for your answers.&lt;BR /&gt;
The partner of my company send me a new log file with more details.....&lt;BR /&gt;
i do apologise for the inconvenience。 本当にごめんなさい！！！&lt;BR /&gt;
On the new log file , I have an event to define the beginning :&lt;BR /&gt;
LOG IN -- &amp;gt; Mar 1 21:45:41 XDSauth: 1488433541 |ConnectorSession.setNextServiceName     |next service name =  X&lt;BR /&gt;
                    Mar 1 21:45:41 XDSauth: 1488433541 |ServiceHdlr.serviceTerminated |next service = X&lt;BR /&gt;
LOG OUT --&amp;gt; Mar 1 21:47:05 XDSauth: 1488433625 |ServiceHdlr.serviceTerminated |next service = X &lt;BR /&gt;
Where X is the user name.&lt;/P&gt;

&lt;P&gt;But the problem is : ServiceHdlr.serviceTerminated&lt;BR /&gt;
I have this event twice.&lt;BR /&gt;
One after ConnectorSession.setNextServiceName and the next is to define the end of connection.&lt;/P&gt;

&lt;P&gt;If I use &lt;BR /&gt;
startswith="ConnectorSession.setNextServiceName" endswith="ServiceHdlr.serviceTerminated"&lt;BR /&gt;
The result is :&lt;BR /&gt;
2017-03-02 14:45:39.000  ConnectorSession.setNextServiceName&lt;BR /&gt;
2017-03-02 14:45:41.000  ServiceHdlr.serviceTerminated&lt;/P&gt;

&lt;P&gt;But the end of the connection is : 2017-03-02 14:46:13.000 &lt;/P&gt;

&lt;P&gt;With this new log file, that's more easier to define the beginning but I have still a problem to define the End.&lt;/P&gt;

&lt;P&gt;Maybe create a condition to select the second event  "ServiceHdlr.serviceTerminated" ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Laurent&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 02:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334513#M99421</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2017-03-03T02:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334514#M99422</link>
      <description>&lt;P&gt;OK, let's assume that login sessions are short.  This means that if the distance between the last 2 events is less than 8 hours, then the last event is a logout and the one before is a login.  If the distance between the last 2 is more than 8 hours, then the last event is a login and the one before is a logout.&lt;/P&gt;

&lt;P&gt;Here is code that fakes some events for testing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=3 
| eval raw="XDSauth: 1488433625 |ServiceHdlr.serviceTerminated |next service =1" 
| streamstats count AS _serial 
| eval _time = _time - _serial 
| append 
    [| makeresults count=5 
    | streamstats count AS _serial 
    | eventstats count AS _total 
    | eval raw="XDSauth: 1488433625 |ServiceHdlr.serviceTerminated |next service =" . round(_serial%(_total/2)) 
    | eval _time = _time - (3000 * _serial * _serial)] 
| rex field=raw "next service\s*=\s*(?&amp;lt;user&amp;gt;.*)$" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then add something like this (tune to fit) to assign the appropriate &lt;CODE&gt;action&lt;/CODE&gt; values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats max(_time) AS recent_time BY user 
| eval recent_time=if((_time=recent_time), recent_time, "NULL") 
| eval secondsSinceLastEvent = now() - recent_time 
| streamstats count(recent_time) AS _count count AS serial BY user 
| eval next_recent_time=if((_count=2), _time, null()) 
| eventstats first(recent_time) AS _first_recent_time first(next_recent_time) AS _first_next_recent_time BY user 
| eval secondsBetweenLastTwoEvents = _first_recent_time - _first_next_recent_time 
| eval action=case((serial&amp;gt;1), null(),
    (secondsSinceLastEvent &amp;gt; secondsBetweenLastTwoEvents), "Login",
    (secondsBetweenLastTwoEvents &amp;gt; (8*60*60)), "Login",
    true(), "Logout") 
| eventstats last(action) AS last_action by user 
| eval action=case(isnotnull(action), action,
    (((serial%2=1) AND (last_action="Login")) OR ((serial%2=0) AND (last_action="Logout"))), "Login",
    true(), "Logout")
| fields - serial seconds* last* *recent_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 02:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334514#M99422</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-03T02:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334515#M99423</link>
      <description>&lt;P&gt;@woodcock &lt;BR /&gt;
Thanks , I try this.&lt;BR /&gt;
But I just received a new log file from the partner.... I hope is not different.....&lt;BR /&gt;
I try your solution and i send a feedback quickly.&lt;BR /&gt;
Best regards, &lt;BR /&gt;
ありがとうございます&lt;BR /&gt;
laurent&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 02:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334515#M99423</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2017-03-03T02:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334516#M99424</link>
      <description>&lt;P&gt;The solution uses some logic to assign the most recent event a designation of either &lt;CODE&gt;Login&lt;/CODE&gt; or &lt;CODE&gt;Logout&lt;/CODE&gt; and from there you just move backwards in time flipping back and forth.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 02:56:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334516#M99424</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-03T02:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334517#M99425</link>
      <description>&lt;P&gt;That's work perfect but with the new log file, I don't use this system.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=XDSauth  | fieldformat Epoch_Time = strftime(Epoch_Time, "%F %T.%3N")  | rex field=_raw ".*\d+\|.+\|\d+\|(?&amp;lt;fld_key&amp;gt;[^ ]+)\s.*" | where User="WIN7-007" |table User, Status , Epoch_Time  , fld_key | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;User                    Status                                                    Epoch_Time                                fld_key&lt;BR /&gt;
WIN7-007    ServiceHdlr.serviceTerminated   2017-03-02 14:47:05.000                           145c414&lt;BR /&gt;
WIN7-007    ServiceHdlr.serviceTerminated   2017-03-02 14:45:41.000                            3a4822&lt;BR /&gt;
WIN7-007    ConnectorSession.setNextServiceName 2017-03-02 14:45:39.000             3a4822&lt;/P&gt;

&lt;P&gt;I want to do that : &lt;BR /&gt;
IF  ConnectorSession.setNextServiceName.fld_key = ServiceHdlr.serviceTerminated.fld_key THEN&lt;BR /&gt;
Delete "WIN7-007    ServiceHdlr.serviceTerminated   2017-03-02 14:45:41.000 3a4822"&lt;/P&gt;

&lt;P&gt;Result: &lt;BR /&gt;
User                    Status                                                    Epoch_Time                                fld_key&lt;BR /&gt;
WIN7-007    ServiceHdlr.serviceTerminated   2017-03-02 14:47:05.000                           145c414&lt;/P&gt;

&lt;P&gt;WIN7-007    ConnectorSession.setNextServiceName 2017-03-02 14:45:39.000             3a4822&lt;/P&gt;

&lt;P&gt;Do you think that's possible to perform that ?&lt;/P&gt;

&lt;P&gt;[ if it's possible after, I do --&amp;gt; | eval FinalStatus = case (Status="ConnectorSession.setNextServiceName","LOGIN")  | eval FinalStatus = case (Status="ServiceHdlr.serviceTerminated","LOGOUT") ]&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334517#M99425</guid>
      <dc:creator>LNebout</dc:creator>
      <dc:date>2020-09-29T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search for the "Log In" and "Log Out" event when they appear to have the same pattern in my logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334518#M99426</link>
      <description>&lt;P&gt;I am confused; we deep enough down this trail that starting over merits an entirely new question.  That is what I would do.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 01:12:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-for-the-quot-Log-In-quot-and-quot-Log-Out-quot/m-p/334518#M99426</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-04T01:12:06Z</dc:date>
    </item>
  </channel>
</rss>

