<?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: Time based counting. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515445#M144723</link>
    <description>&lt;P&gt;HI Ralph,&lt;/P&gt;&lt;P&gt;Sorry If my question didn't gave enough info.&lt;/P&gt;&lt;P&gt;Problem : I have same sitecode giving individual values that happened over the same day.&lt;/P&gt;&lt;P&gt;My aim was to get it that captured together, Like if the sitecode "FAW" created 4 events in 21st Aug, I should get 4 in the count field. But that is not happening based on time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I do below code. am getting correct value as FAW and 4 in table.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by sitecode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my aim was to find out per-day basis how many events generated for each site.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Aug 2020 13:04:41 GMT</pubDate>
    <dc:creator>jerinvarghese</dc:creator>
    <dc:date>2020-08-21T13:04:41Z</dc:date>
    <item>
      <title>Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515429#M144717</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;need your help in getting the count correct for the below table.&lt;/P&gt;&lt;P&gt;Table:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" width="99.87096774193549%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;Time&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;sitecode&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Query:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=moogsoft_e2e 
| eval Time = _time
| fieldformat Time=strftime(Time,"%Y-%m-%d")
| sort - Time
| stats count by Time, sitecode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected output:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;Time&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;sitecode&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40.38709677419355%"&gt;&lt;SPAN&gt;2020-08-21&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="31.870967741935484%"&gt;FAW&lt;/TD&gt;&lt;TD width="27.612903225806452%"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 21 Aug 2020 12:08:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515429#M144717</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-08-21T12:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515432#M144718</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33379"&gt;@jerinvarghese&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;You don't tell us what your issue is. The SPL looks ok.&lt;BR /&gt;&lt;BR /&gt;I guess it is related to the fieldname "count" which could cause Problems with the operator "count" in SPL.&lt;BR /&gt;&lt;BR /&gt;Because all the counts are "1" in your example, it does not make a difference, but try if you want to addup all the counts and you have cases where it's not "1" for all rows.:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(count) by Time, sitecode&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;BR /&gt;--&lt;BR /&gt;&lt;EM&gt;Karma and/or Solution tagging appreciated.&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 12:28:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515432#M144718</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-08-21T12:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515445#M144723</link>
      <description>&lt;P&gt;HI Ralph,&lt;/P&gt;&lt;P&gt;Sorry If my question didn't gave enough info.&lt;/P&gt;&lt;P&gt;Problem : I have same sitecode giving individual values that happened over the same day.&lt;/P&gt;&lt;P&gt;My aim was to get it that captured together, Like if the sitecode "FAW" created 4 events in 21st Aug, I should get 4 in the count field. But that is not happening based on time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I do below code. am getting correct value as FAW and 4 in table.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by sitecode&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But my aim was to find out per-day basis how many events generated for each site.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 13:04:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515445#M144723</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-08-21T13:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515447#M144726</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33379"&gt;@jerinvarghese&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;If I understand your requirement correct now, you should be able to get this with timechart:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1d count by sitecode&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;BR /&gt;&lt;EM&gt;--&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Karma and/or Solution tagging appreciated.&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 13:12:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515447#M144726</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-08-21T13:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515625#M144783</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33379"&gt;@jerinvarghese&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set bin to 1 day before your stats clause&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=moogsoft_e2e 
| eval Time = _time
| fieldformat Time=strftime(Time,"%Y-%m-%d")
| sort - Time
| bin Time span=1d
| stats count by Time, sitecode&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 23 Aug 2020 09:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515625#M144783</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-08-23T09:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515658#M144788</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33379" target="_blank" rel="noopener"&gt;@jerinvarghese&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The issue you have is using &lt;STRONG&gt;fieldformat&lt;/STRONG&gt;&amp;nbsp;for &lt;EM&gt;Time&lt;/EM&gt;&amp;nbsp;field instead of&lt;SPAN&gt;&amp;nbsp;instead of &lt;STRONG&gt;eval.&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;Check the Splunk docs for the difference and you should be able to work out why.&lt;BR /&gt;&lt;BR /&gt;Also note, depending on how much data you are searching, it is far more efficient to do evals/formats after transforming the data set, as it reduces it size.&amp;nbsp; So something like this is better practise...&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=moogsoft_e2e 
| bin _time span=1d
| stats count by _time sitecode
| sort - _time
  `comment("# only if you want to change the column header")`
| fieldformat Time=strftime(_time,"%Y-%m-%d")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Aug 2020 21:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515658#M144788</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2020-08-23T21:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Time based counting.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515970#M144909</link>
      <description>Thanks for the reply, got that worked with Eval before this solution. Seems Eval is simpler than other methods. Sorry to others too. I got the answer worked with eval statement. | eval Time=strftime(_time,"%Y-%m-%d %l:%M:%S %p")</description>
      <pubDate>Tue, 25 Aug 2020 09:15:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-based-counting/m-p/515970#M144909</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-08-25T09:15:55Z</dc:date>
    </item>
  </channel>
</rss>

