<?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: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359472#M5832</link>
    <description>&lt;P&gt;This is a pretty good use case for the &lt;CODE&gt;transaction&lt;/CODE&gt; command; you need &lt;CODE&gt;startswith&lt;/CODE&gt;, &lt;CODE&gt;endswith&lt;/CODE&gt;, and &lt;CODE&gt;maxspan&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Sun, 31 Dec 2017 20:41:28 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-12-31T20:41:28Z</dc:date>
    <item>
      <title>Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359469#M5829</link>
      <description>&lt;P&gt;Happy New Year,&lt;/P&gt;

&lt;P&gt;I'm working on an alert for certain event codes regarding DFS Replication.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlogs sourcetype="WinEventLog:DFS Replication" host=host1 OR host2 OR host3 EventCode=1202 OR 5002 OR 5008 OR 5012 OR 5014 earliest=-5m
| rex "Message=(?&amp;lt;Message&amp;gt;.*)" 
| table _time,Message,ComputerName,EventCode,Error
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to return a result if any of the following EventCodes are found in an event from five minutes ago (EventCode 1202 OR 5002 OR 5008 OR 5012 OR 5014), unless followed by an event with either EventCode 5004 or 1206 (which represent a recovery) within five minutes of the error event code.&lt;/P&gt;

&lt;P&gt;I'm eyeballing the case and validate functions, but I'm having some difficulty putting the picture together.&lt;/P&gt;

&lt;P&gt;Thank you for any assistance.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2017 20:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359469#M5829</guid>
      <dc:creator>danbutterman</dc:creator>
      <dc:date>2017-12-29T20:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359470#M5830</link>
      <description>&lt;P&gt;You'd need to adjust your timerange to allow those recovery events to happen. So you should be looking for error events for say -10m@m to -5m@m (only) and recovery event for -10m@m to now. This way you'd be able to correlate a recovery event with error event. With current 5 min time range, you're alerting prematurely as you may not be allowing a recovery event to be logged yet.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2017 20:22:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359470#M5830</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-12-29T20:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359471#M5831</link>
      <description>&lt;P&gt;This is a bit difficult to validate without sample data, but here's my untested attempt:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlogs sourcetype="WinEventLog:DFS Replication" (host=host1 OR host2 OR host3) (EventCode=1202 OR EventCode=5002 OR EventCode=5008 OR EventCode=5012 OR EventCode=5014 OR EventCode=5004 OR EventCode=1206)
| eval failure_time=if(EventCode=1202 OR EventCode=5002 OR EventCode=5008 OR EventCode=5012 OR EventCode=5014, _time, NULL)
| where isnull(failure_time) OR failure_time&amp;lt;relative_time(now(), "-5min")
| head 1 
| search EventCode=1202 OR EventCode=5002 OR EventCode=5008 OR EventCode=5012 OR EventCode=5014 OR EventCode=5004
| rex "Message=(?&amp;lt;Message&amp;gt;.*)"
| table _time,Message,ComputerName,EventCode,Error
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It takes into consideration @samesonei2's point about only counting "failures" that are at least 5 minutes old.  It intends to find all failure and recovery events, remove failures that aren't 5 minutes old, then only show the most recent event, and further filter to only show it if it's a failure.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2017 21:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359471#M5831</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-12-29T21:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359472#M5832</link>
      <description>&lt;P&gt;This is a pretty good use case for the &lt;CODE&gt;transaction&lt;/CODE&gt; command; you need &lt;CODE&gt;startswith&lt;/CODE&gt;, &lt;CODE&gt;endswith&lt;/CODE&gt;, and &lt;CODE&gt;maxspan&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2017 20:41:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359472#M5832</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-31T20:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359473#M5833</link>
      <description>&lt;P&gt;Hi @danbutterman,&lt;BR /&gt;
I don't know id i understood your question correct, but can you try below query if it helps you.&lt;BR /&gt;
 index=wineventlogs sourcetype="WinEventLog:DFS Replication" host=host1 OR host2 OR host3 EventCode=1202 OR EventCode=5002 OR EventCode=5008 OR EventCode=5012 OR EventCode=5014 OR EventCode=1206 OR EventCode=5004 | search EventCode!=1206 OR EventCode!=5004&lt;BR /&gt;
 | rex "Message=(?.*)" &lt;BR /&gt;
 | table _time,Message,ComputerName,EventCode,Error&lt;/P&gt;

&lt;P&gt;And for timerange you can adjust it with your Custom Time&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2018 10:36:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359473#M5833</guid>
      <dc:creator>nikita_p</dc:creator>
      <dc:date>2018-01-01T10:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359474#M5834</link>
      <description>&lt;P&gt;I will give these a try tomorrow when I’m back in office and send an update.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jan 2018 15:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359474#M5834</guid>
      <dc:creator>danbutterman</dc:creator>
      <dc:date>2018-01-01T15:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359475#M5835</link>
      <description>&lt;P&gt;Woodcock,&lt;/P&gt;

&lt;P&gt;This is the search I perform to find 5014 and 5004 events (for example).&lt;/P&gt;

&lt;P&gt;index=wineventlogs sourcetype="WinEventLog:DFS Replication" host=DC01 OR DC02 OR DC03 EventCode=1202 OR 5002 OR 5008 OR 5012 OR 5014 OR 5004 OR 1206&lt;BR /&gt;
    | rex "Message=(?&lt;MESSAGE&gt;.*)" &lt;BR /&gt;
    | table _time,Message,ComputerName,EventCode,Error&lt;/MESSAGE&gt;&lt;/P&gt;

&lt;P&gt;The first two events that result are as shows below:&lt;/P&gt;

&lt;P&gt;1/1/18&lt;BR /&gt;
11:00:57.000 PM &lt;BR /&gt;
01/01/2018 11:00:57 PM&lt;BR /&gt;
LogName=DFS Replication&lt;BR /&gt;
SourceName=DFSR&lt;BR /&gt;
EventCode=5004&lt;BR /&gt;
EventType=4&lt;/P&gt;

&lt;P&gt;1/1/18&lt;BR /&gt;
11:00:51.000 PM &lt;BR /&gt;
01/01/2018 11:00:51 PM&lt;BR /&gt;
LogName=DFS Replication&lt;BR /&gt;
SourceName=DFSR&lt;BR /&gt;
EventCode=5014&lt;BR /&gt;
EventType=3&lt;/P&gt;

&lt;P&gt;When I add in the transaction command (as follows), no results are returned:&lt;/P&gt;

&lt;P&gt;index=wineventlogs sourcetype="WinEventLog:DFS Replication" host=DC01 OR DC02 OR DC03 EventCode=1202 OR 5002 OR 5008 OR 5012 OR 5014 OR 5004 OR 1206&lt;BR /&gt;
    | rex "Message=(?&lt;MESSAGE&gt;.*)" &lt;BR /&gt;
    | transaction EventCode startswith=5014 endswith=5004 maxspan=5m&lt;/MESSAGE&gt;&lt;/P&gt;

&lt;P&gt;The way I imagine the transaction command is supposed to work using the example above is it finds my 5014 event at 11:00:51 PM (which marks the beginning of a new transaction, specifically where a replication error occurred), and finds the 5004 event at 11:00:57 PM (which marks the end of the transaction); however, nothing is returned.&lt;/P&gt;

&lt;P&gt;I seem to have taken a wrong turn.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 16:24:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359475#M5835</guid>
      <dc:creator>danbutterman</dc:creator>
      <dc:date>2018-01-02T16:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Alert on specific EventCode values unless followed by a specific EventCode within a 5-minute span</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359476#M5836</link>
      <description>&lt;P&gt;One step closer.&lt;/P&gt;

&lt;P&gt;I swapped out the field "EventCode" with "host" and now I'm seeing transactions.&lt;/P&gt;

&lt;P&gt;| transaction host startswith=5014 endswith=5004 maxspan=5m&lt;/P&gt;

&lt;P&gt;Next step would be to change this so that a transaction is created only when a "5004" or "1206" is not found (within 5 minutes of the error event, e.g., 5014 or 5008).&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 16:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Alert-on-specific-EventCode-values-unless-followed-by-a-specific/m-p/359476#M5836</guid>
      <dc:creator>danbutterman</dc:creator>
      <dc:date>2018-01-02T16:53:11Z</dc:date>
    </item>
  </channel>
</rss>

