<?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: Rex problem in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490599#M136988</link>
    <description>&lt;P&gt;I don't see the differences in the latest query.&lt;/P&gt;

&lt;P&gt;The events of the last 3 months will all have Year==2020 and Current_Year==2020.  Therefore, they will all fail &lt;CODE&gt;where Year!=Current_Year&lt;/CODE&gt; and will not be displayed.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:12:23 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-09-30T05:12:23Z</dc:date>
    <item>
      <title>Rex problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490596#M136985</link>
      <description>&lt;P&gt;Hey&lt;BR /&gt;
I'm trying to extract the values from _time to new fields (Year, Month, Day), in order to compare average of events during current month to last 3 months, but it seems like they do not get any value.&lt;/P&gt;

&lt;P&gt;here is my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 'soc_events'
    | search * Rule_Name="*"
    | eval mytime=strftime(_time, "%Y/%m/%d") 
    | 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;</description>
      <pubDate>Mon, 04 May 2020 14:41:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490596#M136985</guid>
      <dc:creator>henderz</dc:creator>
      <dc:date>2020-05-04T14:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rex problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490597#M136986</link>
      <description>&lt;P&gt;The regular expression does not match the data.  Since the 'mytime' field does not contain quotation marks, they should not be in the &lt;CODE&gt;rex&lt;/CODE&gt; command.  Try  &lt;CODE&gt;| rex field=mytime "(?&amp;lt;Year&amp;gt;\d+)/(?&amp;lt;Month&amp;gt;\d+)/(?&amp;lt;Day&amp;gt;\d+)"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;That's not all.  Once you filter out all events from the current year using &lt;CODE&gt;| where Month!=CurrentMonth OR Year!=Current_Year&lt;/CODE&gt; you're likely to have nothing left.&lt;/P&gt;

&lt;P&gt;What problem is this query trying to solve?&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 14:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490597#M136986</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-05-04T14:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rex problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490598#M136987</link>
      <description>&lt;P&gt;well as i said i'm trying compare average of events during current month to last 3 months&lt;/P&gt;

&lt;P&gt;i did few changes that helped a little :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; 'soc_events'
     | search * Rule_Name="*"
     | eval mytime=strftime(_time, "%Y/%m/%d") 
     | 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!=Current_Month 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 now the query does not compare the previous months to this one like i wanted it to&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 15:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490598#M136987</guid>
      <dc:creator>henderz</dc:creator>
      <dc:date>2020-05-04T15:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rex problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490599#M136988</link>
      <description>&lt;P&gt;I don't see the differences in the latest query.&lt;/P&gt;

&lt;P&gt;The events of the last 3 months will all have Year==2020 and Current_Year==2020.  Therefore, they will all fail &lt;CODE&gt;where Year!=Current_Year&lt;/CODE&gt; and will not be displayed.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:12:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-problem/m-p/490599#M136988</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-30T05:12:23Z</dc:date>
    </item>
  </channel>
</rss>

