<?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 edit my search to track consecutive and dual logins by the same user? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315227#M94383</link>
    <description>&lt;P&gt;Ohh yes.. Thanks @DalJeanis for pointing that out. Updated.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2017 02:41:56 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-02-23T02:41:56Z</dc:date>
    <item>
      <title>How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315222#M94378</link>
      <description>&lt;P&gt;Trying to make a table to track login of a user at same time from different IP.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[AzA][][host][12/Mar/2017:**15:28:29** -0600][Agentname][asfafaadvwegwegwevw][**USER=abc**][2412-34234-32235-2323-341342-234234][automatic][as124-4f12c2-fef3-f23f23f3f34d]
[**24.00.00.242**][/abc/aed/dsd][method][][][][qwrqwqsasasdaqwawsadsas][][protect][][][][][]

[AzA][][host][12/Mar/2017:**15:28:40** -0600][Agentname][asfafaadvwegwegwevw][**USER=abc**][2412-34234-32235-2323-341342-234234][automatic][as124-4f12c2-fef3-f23f23f3f34d]
[**23.00.00.4**][/abc/aed/dsd][method][][][][qwrqwqsasasdaqwawsadsas][][protect][][][][][]

[AzA][][host][12/Mar/2017:**15:28:55** -0600][Agentname][asfafaadvwegwegwevw][**USER=abc**][2412-34234-32235-2323-341342-234234][automatic][as124-4f12c2-fef3-f23f23f3f34d][**234.234.244.242**][/abc/aed/dsd][method][][][][qwrqwqsasasdaqwawsadsas][][protect][][][][][]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to make a table with IP like below(Only USER having different IP in log at same second).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;USER         IP1                Time          City                   IP2            Time             City      TIMEDifference(sec)
abc     24.00.00.242    15:28:29     City1         23.00.00.4     15:28:40       City2         11
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying something like below and not sure to join them and get the city field of two IP.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch  ip!=""  USER!=""  |  rename USER AS login| rename ip AS Address | iplocation allfields=true eval first_t=strftime(_time, "%Y-%m-%d %H:%M:%S") | 
eval prev_t=strftime(prev_t, "%Y-%m-%d %H:%M:%S")   | first(ipAddress) as IP1 by login | second(ipAddress) as IP2 by login 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What command I can use to divide the IP as IP1 and IP2 and get city information for respective IP?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 20:17:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315222#M94378</guid>
      <dc:creator>krishnacasso</dc:creator>
      <dc:date>2017-02-22T20:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315223#M94379</link>
      <description>&lt;P&gt;In your example, the logins are within same minute, not same second. Which one is your requirement? So, basically if a user logs in using two different IP, you want to list details for them?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 22:12:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315223#M94379</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-22T22:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315224#M94380</link>
      <description>&lt;P&gt;Sorry I mean logins are at same minute and with different IP.  Yes I want user table who have different IP at same minute. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 22:54:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315224#M94380</guid>
      <dc:creator>krishnacasso</dc:creator>
      <dc:date>2017-02-22T22:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315225#M94381</link>
      <description>&lt;P&gt;Give this a try&lt;BR /&gt;
&lt;STRONG&gt;Updated#3&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch  ip!=""  USER!="" 
| eval Time=_time
| bucket span=1m _time 
| stats list(ip) as IP list(Time) as Time by _time USER
| where mvcount(mvdedup(IP))=2 AND mvcount(IP)=2
| eval IP1=mvindex(IP,0) | iplocation IP1 | rename City as IP1_City
| eval IP2=mvindex(IP,1) | iplocation IP2 | rename City as IP2_City
| eval "TimeDifference(sec)"=abs(tonumber(mvindex(Time,1))-tonumber(mvindex(Time,0)))
| eval IP1_Time=strftime(mvindex(Time,0), "%Y-%m-%d %H:%M:%S")
| eval IP2_Time=strftime(mvindex(Time,1), "%Y-%m-%d %H:%M:%S")
| table USER IP1* IP2* "TimeDifference(sec)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2017 23:15:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315225#M94381</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-22T23:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315226#M94382</link>
      <description>&lt;P&gt;I think you mean &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats list(ip) as IP list(Time) as Time by USER _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2017 00:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315226#M94382</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-23T00:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315227#M94383</link>
      <description>&lt;P&gt;Ohh yes.. Thanks @DalJeanis for pointing that out. Updated.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 02:41:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315227#M94383</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-23T02:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315228#M94384</link>
      <description>&lt;P&gt;Hi Somesoni,&lt;BR /&gt;
Can we give condition like IP1!=IP2 and display a table.&lt;BR /&gt;
Here we are getting the table with IP1 and IP2 same IP. &lt;BR /&gt;
Can we add a filter to list only IP which are not same for the user at same minute.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 14:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315228#M94384</guid>
      <dc:creator>krishnacasso</dc:creator>
      <dc:date>2017-02-23T14:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315229#M94385</link>
      <description>&lt;P&gt;Try the updated#2 answer. I've added a check that both the IPs in field IP are not same.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 15:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315229#M94385</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-23T15:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315230#M94386</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I tried updated2 still getting IP1 and IP2 same IP for some, This table gives all users info whoes IP are same and IP are different. &lt;BR /&gt;
I tried something like below using where IP1!=IP2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch  ip!=""  USER!="" 
 | eval Time=_time
 | bucket span=1m _time 
 | stats list(ip) as IP list(Time) as Time by _time USER
 | where mvcount(mvdedup(IP))=2
 | eval IP1=mvindex(IP,0) | iplocation IP1 | rename City as IP1_City
 | eval IP2=mvindex(IP,1) | iplocation IP2 | rename City as IP2_City | where IP1!=IP2
 | eval IP1_Time=strftime(mvindex(Time,0), "%Y-%m-%d %H:%M:%S")
 | eval IP2_Time=strftime(mvindex(Time,1), "%Y-%m-%d %H:%M:%S") | where IP1_City != IP2_City
 | table USER IP1* IP2* "TimeDifferece(sec)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I took out time difference eval using that in search getting below error. &lt;/P&gt;

&lt;P&gt;Error in 'eval' command: Typechecking failed. '-' only takes numbers.&lt;/P&gt;

&lt;P&gt;Is there any syntax missing.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 17:05:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315230#M94386</guid>
      <dc:creator>krishnacasso</dc:creator>
      <dc:date>2017-02-23T17:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315231#M94387</link>
      <description>&lt;P&gt;We need to change the list(ip) to values(ip) or do a real mvdedup on it before line 5-7.   &lt;/P&gt;

&lt;P&gt;Also, someone might be logged on three times, so the mvcount should test for &amp;gt;1.&lt;/P&gt;

&lt;P&gt;And as long as I'm being picky, we should add an "n" to "TimeDifferece(sec)".&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 19:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315231#M94387</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-23T19:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315232#M94388</link>
      <description>&lt;P&gt;I'm confused. The mvcount(mvdedup(IP)) is matching 2 then , the field IP should have two distinct values. It may be the case that there are multiple records for same IP and thus the later mvindex are resulting in same IP. Similarly, the Time field has all epoch values so, the regular mathematical operation should work just fine. Give updated answer a try.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 19:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315232#M94388</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-23T19:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315233#M94389</link>
      <description>&lt;P&gt;The values function will change the order of the IP and TIME (always ascending), so I had to avoid that. May be a dedup based on _time, USER and ip just before the stats is needed. And yes, it doesn't handle 3 IPs, it could be any number actually.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 19:32:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315233#M94389</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-23T19:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315234#M94390</link>
      <description>&lt;P&gt;So, here we go...&lt;/P&gt;

&lt;P&gt;This first part generates some sample data.  Three  records will come out in one minute, two in another.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start="01/25/2017:23:00:37" end="01/25/2017:23:03:40" increment=27s | eval _time=starttime | table _time | eval USER="joe" | streamstats count | eval Time = _time | eval ip="001.001.001".case(count % 3==0,".000",count%3==1,".001",true(),".002") | table _time USER ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's the meat.  The key is using stats list() for IP and Time, then using mvfind to find the offset of the deduped IPs, grabbing the time that lines up with them.  In the case of more than two, this code will always return the two lowest-numbered IP addresses.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | bucket span=1m _time 
 | stats list(ip) as IP list(Time) as Time by _time USER
 | eval IPnondup=mvdedup(IP)
 | where mvcount(IPnondup)&amp;gt;1
 | eval IP1offset=mvfind(IP,mvindex(IPnondup,0))
 | eval IP2offset=mvfind(IP,mvindex(IPnondup,1))
 | eval IP1=mvindex(IP,IP1offset)| iplocation IP1 | rename City as IP1_City
 | eval IP2=mvindex(IP,IP2offset) | iplocation IP2 | rename City as IP2_City
 | eval IP1_Time=strftime(mvindex(Time,IP1offset), "%Y-%m-%d %H:%M:%S")
 | eval IP2_Time=strftime(mvindex(Time,IP2offset), "%Y-%m-%d %H:%M:%S")
 | eval "TimeDifference(sec)"=abs(tonumber(mvindex(Time,IP1offset))-tonumber(mvindex(Time,IP2offset)))
 | table USER IP1* IP2* "TimeDifference(sec)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2017 19:41:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315234#M94390</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-23T19:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to track consecutive and dual logins by the same user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315235#M94391</link>
      <description>&lt;P&gt;Thank you Jeanis/Somesoni.&lt;BR /&gt;
Update 3 worked perfectly. Thanks for sharing knowledge, Learned few good ways of using eval.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2017 21:52:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-track-consecutive-and-dual-logins-by/m-p/315235#M94391</guid>
      <dc:creator>krishnacasso</dc:creator>
      <dc:date>2017-02-23T21:52:39Z</dc:date>
    </item>
  </channel>
</rss>

