<?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: Can an alert take variables? in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/636234#M14942</link>
    <description>&lt;P&gt;Yes, this is working now.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Phil&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2023 00:15:47 GMT</pubDate>
    <dc:creator>Pip9ball</dc:creator>
    <dc:date>2023-03-28T00:15:47Z</dc:date>
    <item>
      <title>Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635538#M14928</link>
      <description>&lt;P&gt;Hello All -&lt;/P&gt;&lt;P&gt;Is it possible to create a search or alert that is based on dynamic variables?&lt;/P&gt;&lt;P&gt;The end goal I'm trying to achieve is to send an email if any of the tests exceed a 10% increase in run time.&amp;nbsp; I have the following search query which generates a table I want, however I want this to run every night on between versionN and versionN-1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="fe" source="regress_rpt" pipeline="soc" version IN("23ww10b","23ww11a") dut="*" (testlist="*") (testName="*") status="*" earliest=-1mon latest=now() | eval lastTestPathElement=replace(testPath, ".*/" ,"") |search lastTestPathElement="**" | chart
     max(cyclesPerCpuSec) AS max:cyclesPerCpuSec
  BY version lastTestPathElement | transpose header_field=version column_name=test_run
| eval cycles_version_delta=('23ww11a' - '23ww10b')
,diff_percentage=round('cycles_version_delta'/'23ww11a' * 100, 1)
,status=if(diff_percentage &amp;lt; 10, "PASS", "FAIL")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results Table&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;test_run&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;23ww10b&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;23ww11a&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;cycles_version_delta&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;diff_percentage&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;basic_test&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;631.68&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;663.80&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;32.12&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;4.80&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;PASS&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;basic_test.1&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;457.48&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;742.98&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;285.50&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;38.40&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;FAIL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%"&gt;basic_test.2&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;730.04&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;691.25&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;-.38.79&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;-5.60&lt;/TD&gt;&lt;TD width="16.666666666666668%"&gt;PASS&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This search is hard-coded to the version 23ww10b and 23ww11a.&amp;nbsp; I'd like to be able to automatically run this search on the latest version and latest version - 1 as well as send an email if there is any FAIL in the status column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best way to do this, if even possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 18:15:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635538#M14928</guid>
      <dc:creator>Pip9ball</dc:creator>
      <dc:date>2023-03-22T18:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635601#M14931</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254779"&gt;@Pip9ball&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You really have three different problems and yes, they all likely solvable.&lt;BR /&gt;&lt;BR /&gt;1. Find the last 2 latest versions - you should be able to create a search for this from the existing data)&lt;BR /&gt;2. Pass to a search query - use the map command to pass variables into search&lt;BR /&gt;3. Send an email notification if threshold passed&amp;nbsp; (simply create an Alert)&lt;BR /&gt;&lt;BR /&gt;#1 - see if you can work out a search query to find the latest two versions&lt;BR /&gt;&lt;BR /&gt;#2 here's a run anywhere example using the&amp;nbsp;&lt;EM&gt;map&lt;/EM&gt; command to pass in variable values into a search&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval v1="23ww10b"&lt;BR /&gt;,v2="23ww11a"&lt;BR /&gt;| map search="&lt;BR /&gt;| makeresults&lt;BR /&gt;| eval $v1$="5555"&lt;BR /&gt;,$v2$="9999"&lt;BR /&gt;,diff=('$v2$' - '$v1$')&lt;BR /&gt;,pct_diff=(diff/'$v2$' * 100)&lt;BR /&gt;| table $v1$ $v2$ diff pct_diff"&lt;/PRE&gt;&lt;P&gt;Note: map is a looping command so you only want to pass it 1 row with the result field values you pass in, i.e. the versions you find in step #1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_0-1679543048721.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24456i1959A00813569DFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_0-1679543048721.png" alt="yeahnah_0-1679543048721.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;#3 Once you have figured out 1 and 2 simply add a where clause, e.g.&lt;/P&gt;&lt;PRE&gt;...&lt;BR /&gt;| where pct_diff &amp;gt;= 10&lt;/PRE&gt;&lt;P&gt;and save the search as a scheduled Alert.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_1-1679543115527.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24457i9E8D1B37A5096DC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_1-1679543115527.png" alt="yeahnah_1-1679543115527.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With a trigger action to email out if threshold meet.&lt;/P&gt;&lt;P&gt;Hopefully this is clear and there is enough general information to keep you going.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 03:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635601#M14931</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-03-23T03:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635755#M14934</link>
      <description>&lt;P&gt;I have written a search to find the last 2 versions, however I'm not sure how to store these results as a variable that I can then use.&lt;/P&gt;&lt;P&gt;Here is my search:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="fe" source="regress_rpt" pipeline="soc" version IN(*) earliest=-1mon latest=now() |dedup version| table version | sort 2 -_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns a table resembling:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%" height="25px"&gt;version&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="25px"&gt;23ww11a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%" height="40px"&gt;&lt;P&gt;23ww10b&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've saved this search as a report named "last2versons"&lt;/P&gt;&lt;P&gt;I'm not sure how to create a variable and extract the table cell data.&amp;nbsp; Ideally I want to assign $versionB to 23ww11a and $versionA to 23ww10b.&amp;nbsp; If I had these set, I could then use the following search.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|savedsearch last2versions SET VARS HERE| search= " index="fe" source="regress_rpt" pipeline="$pipeline$" version IN("$versionA$","$versionB$") dut="*" (testlist="*") (testName="*") status="*" ... "&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 17:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635755#M14934</guid>
      <dc:creator>Pip9ball</dc:creator>
      <dc:date>2023-03-23T17:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635797#M14935</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254779"&gt;@Pip9ball&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's how I'd do it so that the result was a single row with field names versionA and versionB.&lt;/P&gt;&lt;PRE&gt;index="fe" source="regress_rpt" pipeline="soc" version IN(*) earliest=-1mon latest=now()&lt;BR /&gt;| stats count BY _time version ```_time will be in ascending order - newest to oldest ``` &lt;BR /&gt;| head 2&lt;BR /&gt;| transpose&lt;BR /&gt;| rename "row 1" AS versionB "row 2" AS versionA&lt;BR /&gt;| where column="version"&lt;/PRE&gt;&lt;P&gt;Note, using stats command is a far more efficient way to deduplicate fields, as the work will be offloaded to the indexers, especially good if trawling through lots of data.&lt;BR /&gt;&lt;BR /&gt;Now, you can think of a column header name as a field name, which can be passed to the map command.&amp;nbsp; So, stitching it all together, something like this should work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="fe" source="regress_rpt" pipeline="soc" version IN(*) earliest=-1mon latest=now()
| stats count BY _time version  ```_time is ascending order - newest to oldest ``` 
| head 2
| transpose
| rename "row 1" AS versionB "row 2" AS versionA
| where column="version"
| map search="index="fe" source="regress_rpt" pipeline="soc" version IN("$versionA$","$versionB$") dut="*" (testlist="*") (testName="*") status="*" earliest=-1mon latest=now()
  | eval lastTestPathElement=replace(testPath, ".*/" ,"")
  | search lastTestPathElement="**"
  | chart max(cyclesPerCpuSec) AS max:cyclesPerCpuSec
    BY version lastTestPathElement
  | transpose header_field=version column_name=test_run
  | eval cycles_version_delta=('$versionB$' - '$versionA$')
        ,diff_percentage=round('cycles_version_delta'/'$versionB$' * 100, 1)
        ,status=if(diff_percentage &amp;lt; 10, "PASS", "FAIL")
  "
| where status="FAIL"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Hopefully,&amp;nbsp; no typos above but can't validate without data.&lt;/P&gt;&lt;P&gt;I don't think the savedsearch command and passing variables in really works in this case - you'll still have to use map somewhere.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If I was going to improve it, I'd look to have a lookup file listing the different versions in time order.&amp;nbsp; A scheduled search could update it once a day, or at the required frequency to keep it accurate.&amp;nbsp; Then the lookup could be used to quickly find the two latest version and pass it to the map search.&amp;nbsp; That would likely speed up the search.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 23:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635797#M14935</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-03-23T23:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635950#M14936</link>
      <description>&lt;P&gt;Thanks for the help, I'm getting closer but still not quite there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I took your advice and created a lookup csv to add the versions based on time and I'm not looking them up to grab the latest 2 versions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my search, I'm getting a warning saying the query couldn't be run and I don't know how to go about debugging what is wrong.&amp;nbsp; Strangely enough, if I copy/paste the exact query in a new search it runs just fine.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|inputlookup gk_versions.csv | head 2 | transpose
| rename "row 1" AS versionB "row 2" AS versionA
| where column="version" | map search="source=\"regress_rpt\" pipeline=\"soc-fshbd-a0\" version IN(\"$versionA$\",\"$versionB$\") dut=\"*\" testlist=\"*\" testName=\"*\" status=\"*\" earliest=-1mon latest=now()
  | eval lastTestPathElement=replace(testPath, \".*/\" ,\"\")
  | search lastTestPathElement=\"**\"
  | chart max(cyclesPerCpuSec) AS max:cyclesPerCpuSec
    BY version lastTestPathElement
  | transpose header_field=version column_name=test_run
  | eval cycles_version_delta=('$versionB$' - '$versionA$')
        ,diff_percentage=round('cycles_version_delta'/'$versionB$' * 100, 1)
        ,status=if(diff_percentage &amp;lt; 10, \"PASS\", \"FAIL\")
  "&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pip9ball_0-1679674939282.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24522i941B895A2B6A0704/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Pip9ball_0-1679674939282.png" alt="Pip9ball_0-1679674939282.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Pip9ball_1-1679674975554.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24523i5732292471FEE1C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Pip9ball_1-1679674975554.png" alt="Pip9ball_1-1679674975554.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea what could be my problem?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 16:23:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/635950#M14936</guid>
      <dc:creator>Pip9ball</dc:creator>
      <dc:date>2023-03-24T16:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/636078#M14937</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254779"&gt;@Pip9ball&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ah sorry,&amp;nbsp;I think you simply need to specify the search command at the start of the map command search string, as the map search is not the implied by being the first SPL command&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_0-1679876271731.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24540i544361322A8C7DEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_0-1679876271731.png" alt="yeahnah_0-1679876271731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/9.0.2209/SearchReference/Search" target="_blank"&gt;https://docs.splunk.com/Documentation/SplunkCloud/9.0.2209/SearchReference/Search&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;So...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|inputlookup gk_versions.csv | head 2 | transpose
| rename "row 1" AS versionB "row 2" AS versionA
| where column="version"
| map search="search source=\"regress_rpt\" pipeline=\"soc-fshbd-a0\" version IN(\"$versionA$\",\"$versionB$\") dut=\"*\" testlist=\"*\" testName=\"*\" status=\"*\" earliest=-1mon latest=now()
  | eval lastTestPathElement=replace(testPath, \".*/\" ,\"\")
  | search lastTestPathElement=\"**\"
  | chart max(cyclesPerCpuSec) AS max:cyclesPerCpuSec
    BY version lastTestPathElement
  | transpose header_field=version column_name=test_run
  | eval cycles_version_delta=('$versionB$' - '$versionA$')
        ,diff_percentage=round('cycles_version_delta'/'$versionB$' * 100, 1)
        ,status=if(diff_percentage &amp;lt; 10, \"PASS\", \"FAIL\")
  "&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;That seemed to fix it for me when I tried it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 00:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/636078#M14937</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-03-27T00:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can an alert take variables?</title>
      <link>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/636234#M14942</link>
      <description>&lt;P&gt;Yes, this is working now.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;-Phil&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 00:15:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Can-an-alert-take-variables/m-p/636234#M14942</guid>
      <dc:creator>Pip9ball</dc:creator>
      <dc:date>2023-03-28T00:15:47Z</dc:date>
    </item>
  </channel>
</rss>

