<?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: Token Date in a search with join in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445612#M126401</link>
    <description>&lt;P&gt;Don't use &lt;CODE&gt;join&lt;/CODE&gt; like that, use &lt;CODE&gt;stats&lt;/CODE&gt; and &lt;CODE&gt;OR&lt;/CODE&gt; instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; earliest=-15d@d latest=now index=wineventlog (EventCode="4624" OR EventCode="4634") 
| regex Account_Name!=".*\$"                     
| eval Day=strftime(_time,"%d/%m/%Y")   
| eval User=if(mvcount(Account_Name) &amp;gt; 1, mvindex(Account_Name,1), Account_Name)
| eval login_time = case(EventCode="4624", _time),  logoff_time = case(EventCode="4634", _time)
| stats earliest(login_time) as desde, latest(logoff_time) as hasta by User, host, Day
| eval segundos_usados=hasta-desde 
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will go through both event codes together, and stats-by the two together for each user-host-day triple.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Dec 2018 21:32:51 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2018-12-26T21:32:51Z</dc:date>
    <item>
      <title>Token Date in a search with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445611#M126400</link>
      <description>&lt;P&gt;I have this search. My problem is that the result only results in seven days. If I do only the first part, before the Union, the result is correct, but when I execute the two searches, the results are not correct.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;earliest=-15d@d latest=now index=wineventlog (EventCode="4624") 
|regex Account_Name!=".*\$"                     
|eval Day=strftime(_time,"%d/%m/%Y")   
|eval User=mvindex(Account_Name,1)     
|eval Time=strftime(_time,"%d/%m/%Y %H.%M.%S")
|stats earliest(Time) as PrimerLogin by User,host,Day  
|eval desde=strptime(PrimerLogin,"%d/%m/%Y %H.%M.%S") 
|join  User,host,Day
[search earliest=-15d@d latest=now index=wineventlog (EventCode="4634")  
|regex Account_Name!=".*\$"
|eval Day=strftime(_time,"%d/%m/%Y")
|eval User=Account_Name
|eval Time=strftime(_time,"%d/%m/%Y %H.%M.%S")
|stats latest(Time) as UltimoLogoff by User,host,Day 
|eval hasta= strptime(UltimoLogoff,"%d/%m/%Y %H.%M.%S")
]
|eval segundos_usados=hasta-desde 
|eval diff=if(0&amp;gt;segundos_usados,"Usuario No Deslogeado",tostring(floor((segundos_usados)/(3600))) + "hs" +  tostring(floor((segundos_usados)/(60))%60) + "min" )
|stats values(PrimerLogin) as Login,values(UltimoLogoff) as Logoff,values(diff) as Duration by User,host,Day
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Dec 2018 18:34:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445611#M126400</guid>
      <dc:creator>yassy</dc:creator>
      <dc:date>2018-12-26T18:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Token Date in a search with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445612#M126401</link>
      <description>&lt;P&gt;Don't use &lt;CODE&gt;join&lt;/CODE&gt; like that, use &lt;CODE&gt;stats&lt;/CODE&gt; and &lt;CODE&gt;OR&lt;/CODE&gt; instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; earliest=-15d@d latest=now index=wineventlog (EventCode="4624" OR EventCode="4634") 
| regex Account_Name!=".*\$"                     
| eval Day=strftime(_time,"%d/%m/%Y")   
| eval User=if(mvcount(Account_Name) &amp;gt; 1, mvindex(Account_Name,1), Account_Name)
| eval login_time = case(EventCode="4624", _time),  logoff_time = case(EventCode="4634", _time)
| stats earliest(login_time) as desde, latest(logoff_time) as hasta by User, host, Day
| eval segundos_usados=hasta-desde 
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will go through both event codes together, and stats-by the two together for each user-host-day triple.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2018 21:32:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445612#M126401</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-12-26T21:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Token Date in a search with join</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445613#M126402</link>
      <description>&lt;P&gt;Hi @yassy,&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. &lt;/P&gt;

&lt;P&gt;Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 21:24:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Token-Date-in-a-search-with-join/m-p/445613#M126402</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2019-01-07T21:24:45Z</dc:date>
    </item>
  </channel>
</rss>

