<?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 Compare field values with field values from events before in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306001#M161572</link>
    <description>&lt;P&gt;Hello, I am currently trying to set up an alert in Splunk by checking my eventdata after events that contain a list of ID's.&lt;BR /&gt;
If an event occurs which has a list of ID's like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ID_LIST=2345,7865,9876&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I want to iterate through every ID in this list and check if the ID has been mentioned in any log ever before. If it can't be found in earlier logs, it should trigger an alert. If it appears in earlier logs, nothing should happen.&lt;/P&gt;

&lt;P&gt;So right now I prepared my event by extracting all ID's from found event into a field. How can I check whether or not the ID has been mentioned before? &lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 13:46:53 GMT</pubDate>
    <dc:creator>ckunath</dc:creator>
    <dc:date>2017-03-30T13:46:53Z</dc:date>
    <item>
      <title>Compare field values with field values from events before</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306001#M161572</link>
      <description>&lt;P&gt;Hello, I am currently trying to set up an alert in Splunk by checking my eventdata after events that contain a list of ID's.&lt;BR /&gt;
If an event occurs which has a list of ID's like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ID_LIST=2345,7865,9876&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I want to iterate through every ID in this list and check if the ID has been mentioned in any log ever before. If it can't be found in earlier logs, it should trigger an alert. If it appears in earlier logs, nothing should happen.&lt;/P&gt;

&lt;P&gt;So right now I prepared my event by extracting all ID's from found event into a field. How can I check whether or not the ID has been mentioned before? &lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 13:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306001#M161572</guid>
      <dc:creator>ckunath</dc:creator>
      <dc:date>2017-03-30T13:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Compare field values with field values from events before</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306002#M161573</link>
      <description>&lt;P&gt;Assuming that you are running this alert every 5 minutes and 60 days is enough backtrack, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar earliest=-60d latest=now [search index=foo sourcetype=bar earliest=-5m latest=now | stats count BY ID | fields ID] | stats latest(_raw) count BY ID | search count=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, it would make better sense to store the &lt;CODE&gt;birthday&lt;/CODE&gt; of each event in a lookup by running a search for &lt;CODE&gt;All time&lt;/CODE&gt; just once like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar | stats min(_time) AS birthday BY ID | outputlooup IDbirthdays
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then do the alert and update like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar earliest=-5m latest=now | lookup IDbirthdays ID OUTPUT birthday | search NOT birthday="*" | stats min(_time) AS birthday latest(_raw) AS _raw BY ID | outputlookup append=true | rename _raw AS latest_raw
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 14:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306002#M161573</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-30T14:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Compare field values with field values from events before</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306003#M161574</link>
      <description>&lt;P&gt;Thanks for your quick answer! &lt;BR /&gt;
The only problem I have is right now is that I have to extract the ID's out of the list first, and store them in a field like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval splitArray=split(_raw,":")
| eval id_only=mvindex(splitArray,1)
| rex field=id_only mode=sed "s/RECEIVE//g"
| eval listID=split(id_only,",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I do the comparison between the values of listID with the values of ID from the main search? In your example you can straight up filter by ID. &lt;BR /&gt;
(I am sorry, I am still pretty inexperienced when it comes to advanced SPL queries)&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 14:43:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306003#M161574</guid>
      <dc:creator>ckunath</dc:creator>
      <dc:date>2017-03-30T14:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compare field values with field values from events before</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306004#M161575</link>
      <description>&lt;P&gt;You really should do a proper field extraction so that &lt;CODE&gt;ID&lt;/CODE&gt; (or &lt;CODE&gt;listID&lt;/CODE&gt;) is automatically extracted at search time as a multivalued field.  That is the only way to go and that is a completely different question.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 15:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-field-values-with-field-values-from-events-before/m-p/306004#M161575</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-30T15:06:57Z</dc:date>
    </item>
  </channel>
</rss>

