<?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 days with events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184754#M53227</link>
    <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;
I have looked all over for a solution but without luck, so i'm approaching you hoping to find a solution.&lt;BR /&gt;
I would like to count the amount of days (not the amount of events) that has events based on a ctime value in the log.&lt;/P&gt;

&lt;P&gt;Sample log:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;1398963749 1398963749 1432 1404320549&lt;BR /&gt;
0 0 10446976 15988 2 4 0&lt;BR /&gt;
DD_Servers_2003-2008_1398963749_FULL.f&lt;BR /&gt;
&lt;EM&gt;NULL&lt;/EM&gt; &lt;EM&gt;NULL&lt;/EM&gt; 0 1 0 2 1399050149 &lt;EM&gt;NULL&lt;/EM&gt; 1 0 0 0 0 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 0 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 777220 1 0 1999619 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 3 1398963602 3 0 &lt;EM&gt;NULL&lt;/EM&gt; &lt;EM&gt;NULL&lt;/EM&gt; 0 1 0 0&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;The first field states the EPOCH time of the event start (i should mention right away that Splunk time is not relevant as it is the time of insertion to the index, not this field)&lt;BR /&gt;
what I do is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index="foo" | convert ctime(bar)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;From here on im stuck as to how to count the amount of days with the event (i.e. 33 days with events)&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:46:31 GMT</pubDate>
    <dc:creator>NaorPenso</dc:creator>
    <dc:date>2020-09-28T16:46:31Z</dc:date>
    <item>
      <title>Count days with events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184754#M53227</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;
I have looked all over for a solution but without luck, so i'm approaching you hoping to find a solution.&lt;BR /&gt;
I would like to count the amount of days (not the amount of events) that has events based on a ctime value in the log.&lt;/P&gt;

&lt;P&gt;Sample log:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;1398963749 1398963749 1432 1404320549&lt;BR /&gt;
0 0 10446976 15988 2 4 0&lt;BR /&gt;
DD_Servers_2003-2008_1398963749_FULL.f&lt;BR /&gt;
&lt;EM&gt;NULL&lt;/EM&gt; &lt;EM&gt;NULL&lt;/EM&gt; 0 1 0 2 1399050149 &lt;EM&gt;NULL&lt;/EM&gt; 1 0 0 0 0 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 0 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 777220 1 0 1999619 0 0 &lt;EM&gt;NULL&lt;/EM&gt; 3 1398963602 3 0 &lt;EM&gt;NULL&lt;/EM&gt; &lt;EM&gt;NULL&lt;/EM&gt; 0 1 0 0&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;The first field states the EPOCH time of the event start (i should mention right away that Splunk time is not relevant as it is the time of insertion to the index, not this field)&lt;BR /&gt;
what I do is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index="foo" | convert ctime(bar)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;From here on im stuck as to how to count the amount of days with the event (i.e. 33 days with events)&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:46:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184754#M53227</guid>
      <dc:creator>NaorPenso</dc:creator>
      <dc:date>2020-09-28T16:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184755#M53228</link>
      <description>&lt;P&gt;I would do it like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="foo"
| bucket ctime span=1d
| stats dc(ctime) as numberofuniquedays
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to check that this makes sense, try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="foo"
| bucket ctime span=1d
| stats count by ctime
| fieldformat ctime=strftime(ctime,"%x %X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BTW, you can get Splunk to use the ctime of the event - and you probably should. It will make a lot of the reports easier and more sensible. Here is how do that:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetypeOfData]
MAX_TIMESTAMP_LOOKAHEAD = 11
TIME_FORMAT = %s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This &lt;CODE&gt;props.conf&lt;/CODE&gt; goes on the indexer(s), or wherever the data is being parsed.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jun 2014 16:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184755#M53228</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-06-01T16:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count days with events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184756#M53229</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks a lot, you steered me to the correct path.&lt;BR /&gt;
it didn't work exactly as i wanted so what i did is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;index="foo" | &lt;BR /&gt;
convert ctime(bar) as Time timeformat=%m/%d/%y  | &lt;BR /&gt;
bucket Time span=1d | &lt;BR /&gt;
stats dc(Time) as numberofuniquedays&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Thanks again!!&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jun 2014 16:26:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-days-with-events/m-p/184756#M53229</guid>
      <dc:creator>NaorPenso</dc:creator>
      <dc:date>2014-06-01T16:26:33Z</dc:date>
    </item>
  </channel>
</rss>

