<?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 to write query for creating alert using lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468043#M131778</link>
    <description>&lt;P&gt;Something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search that returns a record with these fields 
.... do whatever you need to calculate the timestamp here ... 
| table  _time patch_version hostname
| lookup PatchDate.csv Host as hostname OUTPUT MaxAge
| eval MaxAge=concatenate(MaxAge,30)
| eval DaysSinceChange=round((now()-_time)/86400,0) 
| where DaysSinceChange &amp;gt;= MaxAge
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 05 Sep 2019 15:20:51 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2019-09-05T15:20:51Z</dc:date>
    <item>
      <title>How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468041#M131776</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;/P&gt;

&lt;P&gt;I have the events getting ingested as below:&lt;/P&gt;

&lt;P&gt;timestamp     patch_version&lt;BR /&gt;&lt;BR /&gt;
hostname&lt;/P&gt;

&lt;P&gt;Now,I want to create one lookup csv named 'PatchDate' which contains columns with values&lt;/P&gt;

&lt;P&gt;Host,MaxAge&lt;BR /&gt;
default,30&lt;/P&gt;

&lt;P&gt;Now,I want to implement two logic:&lt;/P&gt;

&lt;P&gt;1.For each event received generate the MAXAGE value to be used.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            IF  &amp;lt;hostname&amp;gt; == Host ]
            THEN
                Use the  MaxAge value.
            ELSE
                Use the MaxAge value for ( Host == “default” )
            END-IF
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;OL&gt;
&lt;LI&gt;Calculate the DAYSSINCECHANGE for the 
&amp;nbsp;
Generate current TimeStamp &amp;nbsp;=&amp;gt;   (need to write a rex command as field is not extracted)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;
Calculate Difference between  and  for event&amp;nbsp; =&amp;gt; DIFFERENCE
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IF DIFFERENCE &amp;gt; 30
             THEN It will throw alert.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Kindly help me to build the query.&lt;BR /&gt;
TIA&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468041#M131776</guid>
      <dc:creator>Arpmjdr</dc:creator>
      <dc:date>2019-09-04T13:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468042#M131777</link>
      <description>&lt;P&gt;This sounds a lot like a Fiverr task.&lt;BR /&gt;
We need some example data to determine how to extract the current TimeStamp field.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 19:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468042#M131777</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-04T19:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468043#M131778</link>
      <description>&lt;P&gt;Something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your search that returns a record with these fields 
.... do whatever you need to calculate the timestamp here ... 
| table  _time patch_version hostname
| lookup PatchDate.csv Host as hostname OUTPUT MaxAge
| eval MaxAge=concatenate(MaxAge,30)
| eval DaysSinceChange=round((now()-_time)/86400,0) 
| where DaysSinceChange &amp;gt;= MaxAge
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 15:20:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468043#M131778</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2019-09-05T15:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468044#M131779</link>
      <description>&lt;P&gt;By &lt;CODE&gt;concatenate&lt;/CODE&gt; did you mean &lt;CODE&gt;coalesce&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 17:03:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468044#M131779</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-05T17:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468045#M131780</link>
      <description>&lt;P&gt;modified a little but it has served my purpose. btw, I had to use "coalesce". Thanks to both of you @richgalloway and @DalJeanis  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 05:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468045#M131780</guid>
      <dc:creator>Arpmjdr</dc:creator>
      <dc:date>2019-09-06T05:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to write query for creating alert using lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468046#M131781</link>
      <description>&lt;P&gt;If your problem is resolved, please accept the answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 12:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-query-for-creating-alert-using-lookup/m-p/468046#M131781</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-06T12:04:31Z</dc:date>
    </item>
  </channel>
</rss>

