<?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 Count timechart by column names in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133976#M36608</link>
    <description>&lt;P&gt;Sample log:&lt;/P&gt;

&lt;P&gt;2013-11-01-10:11:34 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-10:11:50 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-10:30:29 userName=def, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-11:11:34 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-12:11:34 userName=xyz, download=1&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;What I need: find the total minutes that INDIVIDUAL user does NOT download anything over the period of time.&lt;/P&gt;

&lt;P&gt;My approach so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="someScr" download&amp;gt;0 | timechart span=1m count(download) by userName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I got:&lt;BR /&gt;
&lt;TABLE&gt;&lt;BR /&gt;
&lt;TBODY&gt;&lt;TR style="text-decoration:underline"&gt;&lt;TH&gt;_time&lt;/TH&gt;&lt;TH&gt;abc&lt;/TH&gt;&lt;TH&gt;def&lt;/TH&gt;&lt;TH&gt;xyz&lt;/TH&gt;&lt;TH&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-10:11:00&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-10:12:00&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-10:13:00&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-10:30:00&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-11:11:00&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;2013-11-01-12:11:00&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;

&lt;P&gt;The goal is to count all the 0 rows for INDIVIDUAL user from the upper table:&lt;BR /&gt;
Sample results&lt;BR /&gt;
&lt;TABLE&gt;&lt;BR /&gt;
&lt;TBODY&gt;&lt;TR style="text-decoration:underline"&gt;&lt;TH&gt;abc&lt;/TH&gt;&lt;TH&gt;def&lt;/TH&gt;&lt;TH&gt;xyz&lt;/TH&gt;&lt;TH&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;118&lt;/TD&gt;&lt;TD&gt;119&lt;/TD&gt;&lt;TD&gt;119&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;

&lt;P&gt;The result table shows that over 2 hours, abc doesn't download anything for 118 minutes, and 119 minutes for def and xyz.&lt;/P&gt;

&lt;P&gt;I would like to do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="someScr" download&amp;gt;0 | timechart span=1m count(download) by userName | count (_time) by userName where VALUE=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm stuck on the last step, that is how do I refer to the user and the field value and apply a where clause.&lt;BR /&gt;
Or is there a better approach.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 08 Nov 2013 03:09:59 GMT</pubDate>
    <dc:creator>harrychen</dc:creator>
    <dc:date>2013-11-08T03:09:59Z</dc:date>
    <item>
      <title>Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133976#M36608</link>
      <description>&lt;P&gt;Sample log:&lt;/P&gt;

&lt;P&gt;2013-11-01-10:11:34 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-10:11:50 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-10:30:29 userName=def, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-11:11:34 userName=abc, download=1&lt;BR /&gt;&lt;BR /&gt;
2013-11-01-12:11:34 userName=xyz, download=1&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;What I need: find the total minutes that INDIVIDUAL user does NOT download anything over the period of time.&lt;/P&gt;

&lt;P&gt;My approach so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="someScr" download&amp;gt;0 | timechart span=1m count(download) by userName
&lt;/CODE&gt;&lt;/PRE&gt;

&l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D&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;

&lt;P&gt;The goal is to count all the 0 rows for INDIVIDUAL user from the upper table:&lt;BR /&gt;
Sample results&lt;BR /&gt;
&lt;TABLE&gt;&lt;BR /&gt;
&lt;TBODY&gt;&lt;TR style="text-decoration:underline"&gt;&lt;TH&gt;abc&lt;/TH&gt;&lt;TH&gt;def&lt;/TH&gt;&lt;TH&gt;xyz&lt;/TH&gt;&lt;TH&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;TR&gt;&lt;TD&gt;118&lt;/TD&gt;&lt;TD&gt;119&lt;/TD&gt;&lt;TD&gt;119&lt;/TD&gt;&lt;/TR&gt;&lt;BR /&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;

&lt;P&gt;The result table shows that over 2 hours, abc doesn't download anything for 118 minutes, and 119 minutes for def and xyz.&lt;/P&gt;

&lt;P&gt;I would like to do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="someScr" download&amp;gt;0 | timechart span=1m count(download) by userName | count (_time) by userName where VALUE=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm stuck on the last step, that is how do I refer to the user and the field value and apply a where clause.&lt;BR /&gt;
Or is there a better approach.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 03:09:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133976#M36608</guid>
      <dc:creator>harrychen</dc:creator>
      <dc:date>2013-11-08T03:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133977#M36609</link>
      <description>&lt;P&gt;Read docs on &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0/SearchReference/Eventstats"&gt;eventstats&lt;/A&gt; and perhaps this will work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="someScr" download&amp;gt;0 | timechart span=1m count(download) by userName | eventstats sum | head 1 | fields - _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might have to fiddle with it a tad, but on a very basic test, this got me a similar result as you are looking for. However, I don't have a dataset with more than one value for a count for an exact replica. This should get you most of the way there, though!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 04:00:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133977#M36609</guid>
      <dc:creator>jtrucks</dc:creator>
      <dc:date>2013-11-08T04:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133978#M36610</link>
      <description>&lt;P&gt;That is not correct. Maybe I didn't make my question clear. I have edited it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 17:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133978#M36610</guid>
      <dc:creator>harrychen</dc:creator>
      <dc:date>2013-11-08T17:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133979#M36611</link>
      <description>&lt;P&gt;You can try this :- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   index=_internal | bucket span=1m _time | stats count by _time|fields - count |eval joinfield=1 | join type=outer max=0 joinfield
[search sourcetype="someScr" download&amp;gt;0 |stats count by userName |fields - count |eval joinfield=1]|fields - joinfield
|join type=outer max=0 _time,userName 
[search sourcetype="someScr" download&amp;gt;0  
|bucket _time span=1m | stats count by _time,userName ] 
| eval count=COALESCE(count,0) |where count=0 |stats count by userName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;SEARCH UPDATED&lt;/H2&gt;

&lt;P&gt;This should work now. In the first section I am taking all the _time value with 1 min interval (assuming you have access to _internal index which generally have data every minute). I am then joining that with unique list of userName which gives me _time and userName for every minute and every userName. Rest is same.&lt;/P&gt;

&lt;P&gt;Explaination:&lt;BR /&gt;
first portion of search (before join) will give a table with all the minutes (for selected timerange) and userName combination. So for 60m period and 3 users, this should give 180 events.&lt;BR /&gt;
the join inner query gives list of user and minute combination for which download &amp;gt; 0 (we don't worry about the count). &lt;BR /&gt;
This is joined left outer with first portion to give list of all minute and userName with corresponding count of events with download &amp;gt;0. For minutes where there was no download &amp;gt;0 (minutes for which there are not corresponding events in join subquery), the count will be NULL which will be converted to 0. Finally filter all rows with count =0 and get a stats of that.&lt;BR /&gt;
The format of final table will be different from what you are expecting.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 18:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133979#M36611</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-11-08T18:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133980#M36612</link>
      <description>&lt;P&gt;I tried your query. Not working so far.&lt;BR /&gt;
I think the bucket command will eliminate the minutes that all users don't have downloads. In my example, it will not list the rows from 2013-11-01-10:12:00 to 2013-11-01-10:29:00 and from 2013-11-01-11:12:00 to 2013-11-01-12:10:00. &lt;/P&gt;

&lt;P&gt;It will just be&lt;/P&gt;

&lt;P&gt;_time   abc def xyz &lt;BR /&gt;
2013-11-01-10:11:00 2   0   0&lt;BR /&gt;
2013-11-01-10:30:00 0   1   0&lt;BR /&gt;
2013-11-01-11:11:00 1   0   0&lt;BR /&gt;
2013-11-01-12:11:00 0   0   1&lt;/P&gt;

&lt;P&gt;thoughts?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 18:55:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133980#M36612</guid>
      <dc:creator>harrychen</dc:creator>
      <dc:date>2013-11-08T18:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count timechart by column names</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133981#M36613</link>
      <description>&lt;P&gt;So I figure it out.&lt;/P&gt;

&lt;P&gt;Instead of counting the "0" numbers, I subtract the active minutes from the query total minutes.&lt;/P&gt;

&lt;P&gt;Here is a sample query:&lt;/P&gt;

&lt;P&gt;sourcetype="dataSrc" download&amp;gt;0  | bucket _time span=1m | stats dc(_time) as "act" by userName | addinfo | eval inact = round((info_max_time - info_min_time)/60 - act,  0) | table userName, act, inact&lt;/P&gt;

&lt;P&gt;Thank you all for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:14:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-timechart-by-column-names/m-p/133981#M36613</guid>
      <dc:creator>harrychen</dc:creator>
      <dc:date>2020-09-28T15:14:25Z</dc:date>
    </item>
  </channel>
</rss>

