<?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: Grouping Events by Both Time and Customer in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295926#M89296</link>
    <description>&lt;P&gt;Thanks, this works great!&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 15:27:42 GMT</pubDate>
    <dc:creator>DGray</dc:creator>
    <dc:date>2017-07-05T15:27:42Z</dc:date>
    <item>
      <title>Grouping Events by Both Time and Customer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295924#M89294</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;Want to alert when a customer's usage suddenly drops.&lt;/P&gt;

&lt;P&gt;Tried breaking recent usage into two time periods: &lt;BR /&gt;
-  "new" events (the previous 10 minutes)&lt;BR /&gt;
-  "old" events (the 10 minutes before that)&lt;/P&gt;

&lt;P&gt;If there are 100 more "old" events than "new" events, I want to raise an alert.&lt;BR /&gt;
I have tried several approaches,  and found the problem unexpectedly tricky. Please help.&lt;/P&gt;

&lt;P&gt;note: All events have a "customer" field, which is one of a couple hundred values. It should be possible to have one query that checks all customers, and returns those that have problems.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=web | eval kind = case(_time&amp;gt;now()-600, "new", _time&amp;gt;now()-1200, "old", true(), "out of scope") | stats count by customer, kind | .... something??&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=web | stats count by customer | eval new_event_count = [search sourcetype=web earliest=-10m | stats count | where customer=customer ??? | return $count] |&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 14:55:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295924#M89294</guid>
      <dc:creator>DGray</dc:creator>
      <dc:date>2017-07-05T14:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Events by Both Time and Customer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295925#M89295</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=web earliest=-20m@m 
| eval period=if(_time&amp;gt;=relative_time(now(),"-10m@m"),"new","old") 
| chart count over customer by period
| where old-new&amp;gt;100
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 15:19:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295925#M89295</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-05T15:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Events by Both Time and Customer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295926#M89296</link>
      <description>&lt;P&gt;Thanks, this works great!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 15:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-Events-by-Both-Time-and-Customer/m-p/295926#M89296</guid>
      <dc:creator>DGray</dc:creator>
      <dc:date>2017-07-05T15:27:42Z</dc:date>
    </item>
  </channel>
</rss>

