<?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 search a weekly total and daily average per week for 4 weeks per IP address? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134820#M36834</link>
    <description>&lt;P&gt;what happens if you take out &lt;CODE&gt;ipAddress="*"&lt;/CODE&gt; as well in the search?&lt;/P&gt;</description>
    <pubDate>Wed, 26 Nov 2014 09:55:13 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2014-11-26T09:55:13Z</dc:date>
    <item>
      <title>How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134812#M36826</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;After struggling for some time now I turn to you guys for help. The community page have been a great aid but I'm stuck and hope someone can show me a way out.&lt;/P&gt;

&lt;P&gt;Every workday I scan a different range of our network for printers, same range is scanned every Monday and so on. From the printers I find I pull the counter info. The final data that goes into splunk looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;08/10/14 03:10:50
"Model"="Aficio MP 5001"
"Vendor"="RICOH"
"ipAddress"="10.101.31.200"
"MachineTotal"="173060"
"CopyTotal"="143463"
"PrintTotal"="21295"
"FaxTotal"="8302"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From this data I managed to get the week total and from that the daily average with this search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=txt
| eventstats latest(_time) as latest_time
| where _time&amp;lt;relative_time(latest_time,"-7d")
| stats range(MachineTotal) as weektotal by ipAddress
| eval weekcount=round(weekcount)
| join[search]
| fieldformat daily_average=round(weekcount/5)
| fields ipAddress, daily_average, weekcount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I can't find out is how to do this for a 4 week period. So that I get something like: ipAddress, Week_1_daily_average, Week_1_weekcount, Week_2_daily_average, Week_2_weekcount, Week_3_daily_average, Week_3_weekcount, Week_4_daily_average, Week_4_weekcount&lt;/P&gt;

&lt;P&gt;Thank you in advance for the help&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:15:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134812#M36826</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2020-09-28T18:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134813#M36827</link>
      <description>&lt;P&gt;Okay, now we have a question and immediatly two questions pop-up in my head:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;why do you have a &lt;CODE&gt;| join [search]&lt;/CODE&gt; in your search
and &lt;/LI&gt;
&lt;LI&gt;do you know the &lt;CODE&gt;timewrap&lt;/CODE&gt; app &lt;A href="https://apps.splunk.com/app/1645/"&gt;https://apps.splunk.com/app/1645/&lt;/A&gt; ? This will do time over time comparison for you&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 25 Nov 2014 21:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134813#M36827</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-25T21:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134814#M36828</link>
      <description>&lt;P&gt;In my actual search the fields list is longer so I also get Vendor, model etc without &lt;CODE&gt;| join [search]&lt;/CODE&gt; those fields are empty.&lt;/P&gt;

&lt;P&gt;I tried timewrap but I always get stuck because of the calculations I have to do first.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2014 21:46:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134814#M36828</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2014-11-25T21:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134815#M36829</link>
      <description>&lt;P&gt;sorry but this makes no sense, having empty fields because you don't use a &lt;CODE&gt;| join [search]&lt;/CODE&gt; ... so where are these filed coming from if not from your base search? other index? So please: put your actual search here and if possible some actual events and the expected result - thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2014 21:52:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134815#M36829</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-25T21:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134816#M36830</link>
      <description>&lt;P&gt;the search is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=txt ipAddress="*" | eventstats latest(_time) as latest_time | where _time&amp;lt;relative_time(latest_time,"-7d") | stats range(MachineTotal) as Weekcount by ipAddress | eval Weekcount=round(Weekcount) | join[search] |fieldformat Daycount=round(Weekcount/5) | fields HostName, ipAddress, macAddress, Firmware, Serial, SystemUpTime, Vendor, Model, Contact, Location, Daycount, Weekcount, MachineTotal, PrinterTotal, CopieTotal, FaxTotal

HostName ipAddress macAddress Firmware Serial SystemUpTime Vendor Model Contact Location Daycount Weekcount MachineTotal PrinterTotal CopieTotal FaxTotal
P000824 10.101.225.227 0:26:73:36:2e:db 3.06 V9513401741 4:21:14:26.00   Ricoh Aficio MP C4501  VG-JP Wavre 1719    8594    170858  46986   2
P000729 10.101.31.200  0:26:73:37:ac:f9 1.02 V8013500447 19:2:52:39.00   Ricoh Aficio MP 5001               1164    5820    180623  23430   8653
P000728 10.101.55.200  0:26:73:36:bd:8b 1.02 V8013500398 61:1:49:51.00   Ricoh Aficio MP 5001               427     2137    68921   19927   0
P000730 10.101.55.201  0:26:73:37:ac:fa 1.03 V8013500458 36:0:57:52.00   Ricoh Aficio MP 5001               1503    7515    220973  11099   11344
P000825 10.102.225.227 0:26:73:36:1c:69 3.06 V9513401748 104:22:40:52.00 Ricoh Aficio MP C4501  VG-JP Wavre 2567    12835   214880  58382   2
P310055 10.102.225.249 0:26:73:80:78:21 3.18 W914P104818 60:3:32:36.00   Ricoh Aficio MP 301                163     814     6836    4067    2065
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Nov 2014 22:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134816#M36830</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2014-11-25T22:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134817#M36831</link>
      <description>&lt;P&gt;If I do this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=txt ipAddress="*" | eventstats latest(_time) as latest_time | where _time&amp;lt;relative_time(latest_time,"-7d") | stats range(MachineTotal) as Weekcount by ipAddress | eval Weekcount=round(Weekcount) |fieldformat Daycount=round(Weekcount/5) | fields HostName, ipAddress, macAddress, Firmware, Serial, SystemUpTime, Vendor, Model, Contact, Location, Daycount, Weekcount, MachineTotal, PrinterTotal, CopieTotal, FaxTotal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the result is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;HostName    ipAddress   macAddress  Firmware    Serial  SystemUpTime    Vendor  Model   Contact     Location    Daycount    Weekcount   MachineTotal    PrinterTotal    CopieTotal  FaxTotal
    10.101.225.153                                  6       31               
    10.101.225.227                                  1719    8594                 
    10.101.31.200                                   1164    5820                 
    10.101.55.200                                   427         2137                 
    10.101.55.201                                   1503    7515                 
    10.102.225.227                                  2567    12835                
    10.102.225.249                                  163         814                  
    10.11.10.248                                        2869    14343                
    10.11.10.249                                        1222    6108                 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Nov 2014 22:29:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134817#M36831</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2014-11-25T22:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134818#M36832</link>
      <description>&lt;P&gt;Hi Cosmoon,&lt;/P&gt;

&lt;P&gt;okay, the missing fields in your second search come from either a different index or sourcetype, because your subsearch in the &lt;CODE&gt;join&lt;/CODE&gt; will search through all indexes and sourcetpyes which are available to you.&lt;/P&gt;

&lt;P&gt;Basically you can identify the sourcetype for the missing fields and add it in the base search like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=txt ipAddress="*" OR sourcetype=&amp;lt;ForTheMissingFields&amp;gt; | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and leave the &lt;CODE&gt;join...&lt;/CODE&gt; out of your search. &lt;/P&gt;

&lt;P&gt;Take a look at this two answer to get an idea how it can be done:&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/185829/how-to-create-a-custom-macro-function-inside-the-s.html#answer-186115"&gt;http://answers.splunk.com/answers/185829/how-to-create-a-custom-macro-function-inside-the-s.html#answer-186115&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html"&gt;http://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-join-append-or-use-of-subsearches.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The first link is something similar to your use case, a time over time comparison search which was originally build by using multiple sub-searches....the second link is about the topic how to compare fields from different sources, sourcetypes or indexes.&lt;/P&gt;

&lt;P&gt;hope this gets you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 07:11:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134818#M36832</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-26T07:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134819#M36833</link>
      <description>&lt;P&gt;Uhmm strange I have only 1 sourcetype and use 1 index.&lt;/P&gt;

&lt;P&gt;Anyway thx for the macro link I look into that right now&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 09:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134819#M36833</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2014-11-26T09:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134820#M36834</link>
      <description>&lt;P&gt;what happens if you take out &lt;CODE&gt;ipAddress="*"&lt;/CODE&gt; as well in the search?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 09:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134820#M36834</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-26T09:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134821#M36835</link>
      <description>&lt;P&gt;same result. &lt;BR /&gt;
Why is it so important to get rid of that | join [search] part?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 10:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134821#M36835</guid>
      <dc:creator>Cosmoon</dc:creator>
      <dc:date>2014-11-26T10:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a weekly total and daily average per week for 4 weeks per IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134822#M36836</link>
      <description>&lt;P&gt;well, it is not &lt;EM&gt;important&lt;/EM&gt; but most of the searches using &lt;CODE&gt;join&lt;/CODE&gt; can be done with &lt;CODE&gt;stats&lt;/CODE&gt; and will be therefore much faster &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2014 11:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-weekly-total-and-daily-average-per-week-for-4/m-p/134822#M36836</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-11-26T11:18:19Z</dc:date>
    </item>
  </channel>
</rss>

