<?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: Alerts Against A CSV in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44733#M558</link>
    <description>&lt;P&gt;Untested, but 'inputcsv' and 'map' should be what you need&lt;/P&gt;

&lt;P&gt;Lets assume your CSV is called alertcheck.csv and the significant field returned by mymacro is 'count'&lt;/P&gt;

&lt;P&gt;The search would be along the lines of :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputcsv alertcheck.csv 
| map search="
    `mymacro(\"$EventValueFilter$\", \"$Earliest$\", \"$Limit$\", \"$Duration$\")`
    | eval EventValueFilter=\"$EventValueFilter$\"
    | eval Earliest=\"$Earliest$\"
    | eval Limit=\"$Limit$\"
    | eval Duration=\"$Duration$\"
" | table EventValueFilter Earliest Limit Duration count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Nov 2012 13:28:18 GMT</pubDate>
    <dc:creator>jonuwz</dc:creator>
    <dc:date>2012-11-26T13:28:18Z</dc:date>
    <item>
      <title>Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44732#M557</link>
      <description>&lt;P&gt;I have a macro saved which takes 4 parameters and is of the form:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source="MySource" $EventValueFilter$ earliest=$Earliest$ | head _time limit=$Limit$ | stats avg(Timing) as Timing | where Timing &amp;gt;= $Duration$&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Which essentially needs to filter events based on a certain attribute for a specified duration, optionally select a sub section of these, calculate the average Timing for that even (Timing is a defined integer value for the events filtered) and return a value when the average is above a certain threshold. Therefore I could call the following:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;CODE&gt;mymacro(LOGINSTEP, -4h, 0, 100)&lt;/CODE&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;which I would want to get the average time for events with LOGINSTEP in their text for the past 4 hrs and detect if this value was &amp;gt;= 100ms. What I would like to do is define a CSV file with a list of potential checks in a similar vein and have 1 alert which iterates over this file and reports on any relevant occurences e.g.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
EventValueFilter,Earliest,Limit,Duration&lt;BR /&gt;
LOGINSTEP,-1h,0,100&lt;BR /&gt;
HOMEPAGE,-1h,5,50&lt;BR /&gt;
SEARCHRESULTS,-5m,500&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I have the lookup file/definition set up and the above macro so I was looking how I can use these two within a Search to alert me?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 11:04:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44732#M557</guid>
      <dc:creator>paddy3883</dc:creator>
      <dc:date>2012-11-26T11:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44733#M558</link>
      <description>&lt;P&gt;Untested, but 'inputcsv' and 'map' should be what you need&lt;/P&gt;

&lt;P&gt;Lets assume your CSV is called alertcheck.csv and the significant field returned by mymacro is 'count'&lt;/P&gt;

&lt;P&gt;The search would be along the lines of :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputcsv alertcheck.csv 
| map search="
    `mymacro(\"$EventValueFilter$\", \"$Earliest$\", \"$Limit$\", \"$Duration$\")`
    | eval EventValueFilter=\"$EventValueFilter$\"
    | eval Earliest=\"$Earliest$\"
    | eval Limit=\"$Limit$\"
    | eval Duration=\"$Duration$\"
" | table EventValueFilter Earliest Limit Duration count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2012 13:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44733#M558</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-26T13:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44734#M559</link>
      <description>&lt;P&gt;Thanks for this, I've tried to get it working but something strange happening - when I run this:&lt;/P&gt;

&lt;P&gt;| inputcsv Example.csv&lt;BR /&gt;
| map search="&lt;CODE&gt;mymacro($EventValueFilter$, $Earliest$, $Limit$, $Duration$)&lt;/CODE&gt;&lt;BR /&gt;
| eval EventValueFilter=$EventValueFilter$&lt;BR /&gt;
| eval Earliest=\"$Earliest$\"&lt;BR /&gt;
| eval Limit=$Limit$&lt;BR /&gt;
| eval Duration=$Duration$ "&lt;/P&gt;

&lt;P&gt;I get the following message:&lt;/P&gt;

&lt;P&gt;Unable to run query '&lt;CODE&gt;mymacro(LOGINSTEP, -1h, 0, 800)&lt;/CODE&gt; | eval EventValueFilter=LOGINSTEP | eval Earliest="-1h" | eval Limit=0 | eval Duration=800'.&lt;/P&gt;

&lt;P&gt;However if I run the generated query above directly in a search then I get the results!!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 15:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44734#M559</guid>
      <dc:creator>paddy3883</dc:creator>
      <dc:date>2012-11-26T15:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44735#M560</link>
      <description>&lt;P&gt;oops - need backticks around the macro - updated&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 15:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44735#M560</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-26T15:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44736#M561</link>
      <description>&lt;P&gt;Yes, I put those in on my query, and another $ at the end of Duration in the parameter list, still can't understand why I get the message when I run the script, but executing the generated query displays the results?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 15:56:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44736#M561</guid>
      <dc:creator>paddy3883</dc:creator>
      <dc:date>2012-11-26T15:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Alerts Against A CSV</title>
      <link>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44737#M562</link>
      <description>&lt;P&gt;Hmm. Apologies for leading you up the garden path.&lt;BR /&gt;
This might be a bug.&lt;BR /&gt;
&lt;A href="http://splunk-base.splunk.com/answers/60729/macro-inside-subsearch-fails-with-error-showing-literal"&gt;this has been reported before&lt;/A&gt;. macros dont seem to expand in 'map'&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 16:32:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerts-Against-A-CSV/m-p/44737#M562</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-26T16:32:41Z</dc:date>
    </item>
  </channel>
</rss>

