<?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: How to display date info from past weeks? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315548#M94455</link>
    <description>&lt;P&gt;Hi  senthamilselvanj,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=p___ AND error* by sourcetype,_time span=1d 
| bin _time span=1d 
| stats count AS Count by _time sourcetype 
| eval "Day of the week"=strftime(_time,"%A"), Date=strftime(_time,"%m-%d-%Y") 
| table sourcetype Date "Day of the week" Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2017 12:36:57 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-09-01T12:36:57Z</dc:date>
    <item>
      <title>How to display date info from past weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315547#M94454</link>
      <description>&lt;P&gt;&lt;STRONG&gt;My Query:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;| tstats count where index=p___ AND error* by sourcetype,_time span=1d | eval count=tostring(count,"commas") |eval Day=strftime(_time,"%A") | eval Date=strftime(_time,"%m-%d-%Y") | stats list by sourcetype | rename list(Date) as Date list(Day) as "Day of the week" list(count) as Count | table sourcetype Date "Day of the week" Count&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;BR /&gt;
sourcetype          Date            Day of the week     Count&lt;/P&gt;

&lt;P&gt;p____db2           08-26-2017       Saturday          4,44&lt;BR /&gt;
                       08-27-2017       Sunday            6,24&lt;/P&gt;

&lt;P&gt;p____syslog       08-27-2017        Sunday                  45&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Expected Output&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;sourcetype          Date            Day of the week     Count&lt;/P&gt;

&lt;P&gt;p____db2           08-26-2017       Saturday        4,44&lt;BR /&gt;
                       08-27-2017       Sunday          6,24&lt;/P&gt;

&lt;P&gt;p____syslog        08-26-2017       Saturday        Not Available&lt;BR /&gt;
                       08-27-2017       Sunday          45&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:35:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315547#M94454</guid>
      <dc:creator>senthamilselvan</dc:creator>
      <dc:date>2020-09-29T15:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to display date info from past weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315548#M94455</link>
      <description>&lt;P&gt;Hi  senthamilselvanj,&lt;BR /&gt;
try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=p___ AND error* by sourcetype,_time span=1d 
| bin _time span=1d 
| stats count AS Count by _time sourcetype 
| eval "Day of the week"=strftime(_time,"%A"), Date=strftime(_time,"%m-%d-%Y") 
| table sourcetype Date "Day of the week" Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 12:36:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315548#M94455</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-01T12:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to display date info from past weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315549#M94456</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;Thank you for the response. But i didn't get what i expected. Let me explain again.&lt;/P&gt;

&lt;P&gt;We have 3 source types in an index. On one particular day  i was searching the logs using the query (index=pdoa error* | stats count by sourcetype)&lt;/P&gt;

&lt;P&gt;We have received out as below, for sourcetype1 , we have error on both sat &amp;amp; sun. for sourcetype2, we have error message on only Saturday. &lt;/P&gt;

&lt;P&gt;sourcetype Date Day of the week Count&lt;BR /&gt;
p_&lt;STRONG&gt;&lt;EM&gt;db2 08-26-2017 Saturday 4,44&lt;BR /&gt;
                 08-27-2017 Sunday 6,24&lt;BR /&gt;
p&lt;/EM&gt;&lt;/STRONG&gt;_syslog 08-27-2017 Saturday 45&lt;BR /&gt;
The requirement is like, if no error message like sourcetype2 also we have to populate the details as below.&lt;/P&gt;

&lt;H3&gt;p____syslog 08-27-2017 Saturday 0&lt;/H3&gt;

&lt;P&gt;As of now we are not getting any row populating.  &lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Selvan&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 13:29:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315549#M94456</guid>
      <dc:creator>senthamilselvan</dc:creator>
      <dc:date>2017-09-01T13:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to display date info from past weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315550#M94457</link>
      <description>&lt;P&gt;Hi senthamilselvanj,&lt;BR /&gt;
try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=p___ AND error* by sourcetype,_time span=1d 
| timechart span=1d count AS Count by sourcetype
| untable _time sourcetype Count
| eval "Day of the week"=strftime(_time,"%A"), Date=strftime(_time,"%m-%d-%Y") 
| table sourcetype Date "Day of the week" Count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2017 14:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315550#M94457</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-09-01T14:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to display date info from past weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315551#M94458</link>
      <description>&lt;P&gt;One of the nice things about &lt;CODE&gt;timechart&lt;/CODE&gt; is that it creates empty buckets for you ( &lt;CODE&gt;count=0&lt;/CODE&gt; ), so let's leverage that by inserting these 2 lines:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart limit=0 useother=f span=1d count by sourcetype
| untable _time sourcetype count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count where index=p___ AND error* by sourcetype,_time span=1d

| timechart limit=0 useother=f span=1d count by sourcetype
| untable _time sourcetype count

| eval count=tostring(count,"commas")
| eval Day=strftime(_time,"%A")
| eval Date=strftime(_time,"%m-%d-%Y")
| stats list by sourcetype
| rename list(Date) as Date list(Day) as "Day of the week" list(count) as Count
| table sourcetype Date "Day of the week" Count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Sep 2017 21:01:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-date-info-from-past-weeks/m-p/315551#M94458</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-02T21:01:26Z</dc:date>
    </item>
  </channel>
</rss>

