<?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 Timechart of open sessions per username. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54955#M13402</link>
    <description>&lt;P&gt;I have a file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time,User-Name,Action
Thu Mar 7 15:09:22,admin,login
Thu Mar 7 17:46:21,admin,login
Thu Mar 7 18:01:33,admin,logout
Thu Mar 7 18:17:23,1111,login
Thu Mar 7 18:37:02,admin,login
Thu Mar 7 19:00:02,admin,logout
Thu Mar 7 19:05:21,admin,logout
Thu Mar 7 20:51:23,1111,logout
Thu Mar 7 21:10:45,admin,logout
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to plot a timechart of open sessions per each user in the log file.  Having read &lt;A href="http://splunk-base.splunk.com/answers/5547/"&gt;this&lt;/A&gt;&lt;BR /&gt;
 and &lt;A href="http://splunk-base.splunk.com/answers/3347/timechart-of-running-sum"&gt;this&lt;/A&gt; discussions, I wrote this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="Accounting01" | eval Diff=if(Action="login", 1, if(Action="logout", -1, 0)) | bin _time | stats sum(Diff) as OpenSessions by _time User_Name | streamstats sum(OpenSessions) as OpenSessions by User_Name | eval Str_Time=strftime(_time, "%d-%m-%Y %H:%M:%S") | chart max(OpenSessions) as "Open sessions" by User_Name, Str_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is how it looks now:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/j2JD4Ow.png" alt="timechart.png" /&gt;&lt;/P&gt;

&lt;P&gt;The problem is that some of the data is not shown, e. g. there is seemingly 0 sessions for &lt;CODE&gt;admin&lt;/CODE&gt; between 18:00 and 18:35 while from the data it is obvious that they were logged in the whole time.  Same with &lt;CODE&gt;1111&lt;/CODE&gt;: they should have 1 session for every point in time until they log out.  It is more obviously reflected in the tabular version of the data:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/0XlK6di.png" alt="tabular.png" /&gt;&lt;/P&gt;

&lt;P&gt;Is it possible to alter the query so that the running sum per each user is stored per each event, even if it is 0 the whole time?&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;CODE&gt;inputs.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///home/user/tmp/accounting01.csv]
disabled = false
sourcetype = Acc01
source = Accounting01
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Acc01]
REPORT-rep = Acc01_Fields
TRANSFORMS-skip = Skip_Header
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;transforms.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Acc01_Fields]
DELIMS = ","
FIELDS = "Time", "User_Name", "Action"

[Skip_Header]
REGEX = Time,
DEST_KEY = queue
FORMAT = nullQueue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Mar 2013 19:59:08 GMT</pubDate>
    <dc:creator>MikhailArefiev</dc:creator>
    <dc:date>2013-03-07T19:59:08Z</dc:date>
    <item>
      <title>Timechart of open sessions per username.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54955#M13402</link>
      <description>&lt;P&gt;I have a file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time,User-Name,Action
Thu Mar 7 15:09:22,admin,login
Thu Mar 7 17:46:21,admin,login
Thu Mar 7 18:01:33,admin,logout
Thu Mar 7 18:17:23,1111,login
Thu Mar 7 18:37:02,admin,login
Thu Mar 7 19:00:02,admin,logout
Thu Mar 7 19:05:21,admin,logout
Thu Mar 7 20:51:23,1111,logout
Thu Mar 7 21:10:45,admin,logout
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to plot a timechart of open sessions per each user in the log file.  Having read &lt;A href="http://splunk-base.splunk.com/answers/5547/"&gt;this&lt;/A&gt;&lt;BR /&gt;
 and &lt;A href="http://splunk-base.splunk.com/answers/3347/timechart-of-running-sum"&gt;this&lt;/A&gt; discussions, I wrote this query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="Accounting01" | eval Diff=if(Action="login", 1, if(Action="logout", -1, 0)) | bin _time | stats sum(Diff) as OpenSessions by _time User_Name | streamstats sum(OpenSessions) as OpenSessions by User_Name | eval Str_Time=strftime(_time, "%d-%m-%Y %H:%M:%S") | chart max(OpenSessions) as "Open sessions" by User_Name, Str_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is how it looks now:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/j2JD4Ow.png" alt="timechart.png" /&gt;&lt;/P&gt;

&lt;P&gt;The problem is that some of the data is not shown, e. g. there is seemingly 0 sessions for &lt;CODE&gt;admin&lt;/CODE&gt; between 18:00 and 18:35 while from the data it is obvious that they were logged in the whole time.  Same with &lt;CODE&gt;1111&lt;/CODE&gt;: they should have 1 session for every point in time until they log out.  It is more obviously reflected in the tabular version of the data:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://i.imgur.com/0XlK6di.png" alt="tabular.png" /&gt;&lt;/P&gt;

&lt;P&gt;Is it possible to alter the query so that the running sum per each user is stored per each event, even if it is 0 the whole time?&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;CODE&gt;inputs.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///home/user/tmp/accounting01.csv]
disabled = false
sourcetype = Acc01
source = Accounting01
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Acc01]
REPORT-rep = Acc01_Fields
TRANSFORMS-skip = Skip_Header
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;transforms.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Acc01_Fields]
DELIMS = ","
FIELDS = "Time", "User_Name", "Action"

[Skip_Header]
REGEX = Time,
DEST_KEY = queue
FORMAT = nullQueue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Mar 2013 19:59:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54955#M13402</guid>
      <dc:creator>MikhailArefiev</dc:creator>
      <dc:date>2013-03-07T19:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart of open sessions per username.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54956#M13403</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Diff=if(Action="login", 1, if(Action="logout", -1, 0)) | reverse | streamstats sum(Diff) as openSessions by User_Name | timechart max(openSessions) by User_Name | filldown
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Mar 2013 09:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54956#M13403</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-03-08T09:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart of open sessions per username.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54957#M13404</link>
      <description>&lt;P&gt;Thank you!  This is exactly what I was looking for.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2013 10:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-of-open-sessions-per-username/m-p/54957#M13404</guid>
      <dc:creator>MikhailArefiev</dc:creator>
      <dc:date>2013-03-08T10:17:19Z</dc:date>
    </item>
  </channel>
</rss>

