<?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 do I use date_mday to create a table with multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427904#M122482</link>
    <description>&lt;P&gt;Brilliant thank you - clearly a newbie question! Didn't think to combine them. Thanks again.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2018 20:38:21 GMT</pubDate>
    <dc:creator>jnames10</dc:creator>
    <dc:date>2018-08-27T20:38:21Z</dc:date>
    <item>
      <title>How do I use date_mday to create a table with multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427902#M122480</link>
      <description>&lt;P&gt;Hi Splunkers, newish user here...&lt;BR /&gt;
I'm looking at firewall logs, I want to create a table with number of blocked IP for each day, a cumulative daily average, number of daily block events, average events.&lt;/P&gt;

&lt;P&gt;I thought this (which works with a single pair of stats/streamstats lines) would work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=phase1 action=block tag=site1

| stats dc(src) as dailyip by date_mday
| streamstats avg(dailyip) as ip_average

| stats count as dailyevt by date_mday
| streamstats avg(dailyevt) as evt_average

| table date_mday, ip_average, dailyip, dailyevt, evt_average
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and create a table like this....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;date_mday   ip_average  dailyip dailyevt    evt_average
4           3082            3082
5           3439            3260.5
6           3578            3366.33
7           4210            3577.25
8           2545            3370.8
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it doesnt work.... It looks like I cannot use date_mday across 2 strings like that?&lt;/P&gt;

&lt;P&gt;Can someone give me some hints (or a solution!!)?&lt;/P&gt;

&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 19:45:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427902#M122480</guid>
      <dc:creator>jnames10</dc:creator>
      <dc:date>2018-08-27T19:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use date_mday to create a table with multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427903#M122481</link>
      <description>&lt;P&gt;It's not &lt;CODE&gt;date_mday&lt;/CODE&gt; that's throwing you off, it's &lt;CODE&gt;stats&lt;/CODE&gt;.  The second &lt;CODE&gt;stats&lt;/CODE&gt; command is counting the number of results returned by the first &lt;CODE&gt;stats&lt;/CODE&gt; command.  On top of that, there's no time information returned by &lt;CODE&gt;stats&lt;/CODE&gt; so there's nothing to use to calculate &lt;CODE&gt;date_mday&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The good news is you can combine the &lt;CODE&gt;stats&lt;/CODE&gt; commands.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=phase1 action=block tag=site1
| stats dc(src) as dailyip count as dailyevt by date_mday
| streamstats avg(dailyip) as ip_average avg(dailyevt) as evt_average
| table date_mday, ip_average, dailyip, dailyevt, evt_average
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Aug 2018 20:24:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427903#M122481</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-08-27T20:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use date_mday to create a table with multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427904#M122482</link>
      <description>&lt;P&gt;Brilliant thank you - clearly a newbie question! Didn't think to combine them. Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 20:38:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-date-mday-to-create-a-table-with-multiple-fields/m-p/427904#M122482</guid>
      <dc:creator>jnames10</dc:creator>
      <dc:date>2018-08-27T20:38:21Z</dc:date>
    </item>
  </channel>
</rss>

