<?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 you compare a previous average with the current average in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489375#M136699</link>
    <description>&lt;P&gt;so i have tried it, the regex work but it didn't save the value in the new fields (Year, Month, Day)&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2020 13:10:08 GMT</pubDate>
    <dc:creator>henderz</dc:creator>
    <dc:date>2020-05-01T13:10:08Z</dc:date>
    <item>
      <title>How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489371#M136695</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;
I am trying to compare my average events in current month to previous 3 month average (per day [1,2,3...31]) based on _time&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
Considering that the current month is October (10). I am trying to compare the current count of random numbers that I have received on the 10/1 and 10/2 to the average of the counts that I have received on the 1st and 2nd of September(09) and August(08).&lt;/P&gt;

&lt;P&gt;That's how i tried to do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`soc_events`

| eval mytime=strftime(_time, "%Y/%m/%d") | table mytime

| rex field=mytime "("?&amp;lt;Year&amp;gt;\d+)/(?&amp;lt;Month\d+)/(?&amp;lt;Day&amp;gt;\d+)")"

| stats count as Count by Year,Month,Day | sort Year,Month,Day

| eventstats last(Month) as Current_Month last(Year) as Current_Year | where Month!=CurrentMonth OR Year!=Current_Year

| stats avg(Count) as DayAveravge values(Month) as Months by Day
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it says syntax error in rex : missing terminator&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 08:28:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489371#M136695</guid>
      <dc:creator>henderz</dc:creator>
      <dc:date>2020-04-30T08:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489372#M136696</link>
      <description>&lt;P&gt;Hi henderz,&lt;/P&gt;

&lt;P&gt;please have a read about the &lt;CODE&gt;timewrap&lt;/CODE&gt; command &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Timewrap#Examples"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Timewrap#Examples&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;This SPL command provides options to achieve your use case.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 08:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489372#M136696</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-04-30T08:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489373#M136697</link>
      <description>&lt;P&gt;Hey thanks, for the reply&lt;BR /&gt;
I edited my question could you see if  you can help me now?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 11:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489373#M136697</guid>
      <dc:creator>henderz</dc:creator>
      <dc:date>2020-04-30T11:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489374#M136698</link>
      <description>&lt;P&gt;Hi henderz,&lt;/P&gt;

&lt;P&gt;it says your regex is not correct and the reason are the &lt;CODE&gt;"&lt;/CODE&gt; inside the regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=mytime "("?&amp;lt;Year&amp;gt;\d+)/(?&amp;lt;Month\d+)/(?&amp;lt;Day&amp;gt;\d+)")"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;use this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=mytime "(\"?&amp;lt;Year&amp;gt;\d+)/(?&amp;lt;Month\d+)/(?&amp;lt;Day&amp;gt;\d+)\")"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 21:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489374#M136698</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-04-30T21:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489375#M136699</link>
      <description>&lt;P&gt;so i have tried it, the regex work but it didn't save the value in the new fields (Year, Month, Day)&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 13:10:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489375#M136699</guid>
      <dc:creator>henderz</dc:creator>
      <dc:date>2020-05-01T13:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489376#M136700</link>
      <description>&lt;P&gt;Okay, give this a try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1000 
| eval _time=now() - random() 
| eval mytime=strftime(_time, "%Y/%m/%d") 
| table mytime 
| rex field=mytime "(?&amp;lt;Year&amp;gt;\d+)/(?&amp;lt;Month&amp;gt;\d+)/(?&amp;lt;Day&amp;gt;\d+)" 
| stats count as Count by Year,Month,Day 
| sort Year,Month,Day 
| eventstats last(Month) as Current_Month last(Year) as Current_Year 
| where Month!=CurrentMonth OR Year!=Current_Year 
| stats avg(Count) as DayAveravge values(Month) as Months by Day
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The regex did not really work, but I have no idea if the current result is what you expect &lt;CODE&gt;¯\_(ツ)_/¯&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS  &lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 22:04:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489376#M136700</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2020-05-01T22:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare a previous average with the current average</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489377#M136701</link>
      <description>&lt;P&gt;sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=08/01/20 end=11/01/20
| eval _time=starttime, Month=strftime(_time,"%m"), Days=strftime(_time,"%d")
| chart count by Days Month
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`soc_events`
| eval Month=strftime(_time, "%m"), Day=strftime(_time,"%d")
| chart count as Count by Month,Day 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Day,08,09,10
----------
1,XX,YY,ZZ
2,XX,YY,ZZ
3,....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sorry, what's &lt;EM&gt;average&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 22:19:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-a-previous-average-with-the-current-average/m-p/489377#M136701</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-05-01T22:19:47Z</dc:date>
    </item>
  </channel>
</rss>

