<?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: Dashboard - How to trigger second search based on first search where condition is : first result count in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556433#M158025</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235223"&gt;@Luciana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There seems to be some confusion.&lt;/P&gt;&lt;P&gt;I have not put ANY drilldown in my example dashboard.&amp;nbsp; It shows two panels - the first panel runs a search and shows a count. When that search finishes, it will trigger the second search.&lt;/P&gt;&lt;P&gt;Please save that example dashboard as a new dashboard and you will see how it works.&lt;/P&gt;&lt;P&gt;There is no requirement to click anything to drilldown, as the second search runs on the completion of the first search.&lt;/P&gt;&lt;P&gt;This seems to provide the solution for your problem, i.e. NO drilldown is needed to make the second search run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jun 2021 23:52:21 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2021-06-20T23:52:21Z</dc:date>
    <item>
      <title>Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556266#M157958</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Please, Can someone help me here?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Basically , in the first search IF the search stats count &amp;gt;=1 then, a second search would be trigger and then, in this search I could use the sendemail command to send me alert with more information.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;so, considering&amp;nbsp; first query:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index = xxx sourcetype=xxx action=Allowed [|inputlookup OTX | search type=URL | rename indicator as url | table url] |dedup user |stats count&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;lt;condition match="$result.resultCount$&amp;gt;1"&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;then run a&amp;nbsp;second query:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index = xxx sourcetype=xxx action=Allowed [|inputlookup OTX | search type=url | rename indicator as url | table url]&lt;BR /&gt;|dedup user |table _time, hostname, domain, user, serverip, ClientIP |sendemail to="myemail.co.nz" server=smtp.server.co.nz subject="Notification - IOC found by url" message="This is an test message" sendresults=true inline=true format=csv&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you know if is possible, or How Can I do this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I thought about set a token with&amp;nbsp;&lt;BR /&gt;&amp;lt;condition match="$result.resultCount$&amp;gt;1"&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;but then , I dont know how to trigger a second search if the condition is true&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;the second search will be exclusively for sending alerts with more info, it will not be appearing in the dashboard.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you so much&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 02:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556266#M157958</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-18T02:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556267#M157959</link>
      <description>&lt;P&gt;In your second query have a dummy token, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index = xxx sourcetype=xxx action=Allowed $trigger$ [
  |inputlookup OTX | search type=url 
  | rename indicator as url 
  | table url
]
|dedup user 
|table _time, hostname, domain, user, serverip, ClientIP 
|sendemail to="myemail.co.nz" server=smtp.server.co.nz subject="Notification - IOC found by url" message="This is an test message" sendresults=true inline=true format=csv&lt;/LI-CODE&gt;&lt;P&gt;then in your condition statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;condition match="$result.resultCount$&amp;gt;1"&amp;gt;
  &amp;lt;set token="trigger"&amp;gt;true&amp;lt;/set&amp;gt;
&amp;lt;/condition&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;however, once you set that token, the search will not run a second time if the first search runs again.&lt;/P&gt;&lt;P&gt;You can do this to get around that&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;condition match="$result.resultCount$&amp;gt;1"&amp;gt;
  &amp;lt;eval token="trigger"&amp;gt;if(isnull($trigger$),0,$trigger$+1&amp;lt;/eval&amp;gt;
&amp;lt;/condition&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;See this simple dashboard example. The first panel will make a search and then increase the trigger value, which will then cause the second panel to rerun its search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;trigger&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_audit earliest=-1m latest=now
        | stats count
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
          &amp;lt;done&amp;gt;
            &amp;lt;condition match="$job.resultCount$&amp;amp;gt;0"&amp;gt;
              &amp;lt;eval token="trigger"&amp;gt;if(isnull($trigger$),0,$trigger$+1)&amp;lt;/eval&amp;gt;
              &amp;lt;!--&amp;lt;set token="trigger"&amp;gt;true&amp;lt;/set&amp;gt;--&amp;gt;
            &amp;lt;/condition&amp;gt;
          &amp;lt;/done&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Trigger=$trigger$&amp;lt;/title&amp;gt;
      &amp;lt;single&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=_audit $trigger$ earliest=-2m latest=-1m
        | stats count&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/single&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Jun 2021 03:18:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556267#M157959</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-18T03:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556272#M157962</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;, thanks for your answer. I really appreciate.&lt;/P&gt;&lt;P&gt;I will give a try in your suggestion, but&amp;nbsp;I have a question:&lt;/P&gt;&lt;P&gt;You said that I should add a token&lt;STRONG&gt; in the second&amp;nbsp; query&lt;/STRONG&gt;, but in your dashboard you are adding a drilldown in the first query.&amp;nbsp; &amp;nbsp;Was intentional or just an example?&lt;/P&gt;&lt;P&gt;When I saw your model of dashboard I was in doubt how to integrate this in my current dashboard.&amp;nbsp;&amp;nbsp;&lt;FONT face="arial black,avant garde"&gt;Please, let me explain better:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I already have a dashboard that shows the status count.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't use the sendemail in the first query, because it only shows the number of IOCs found, but it does not give me any detail &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp; &amp;nbsp;In my current dashboard,&amp;nbsp; I have&amp;nbsp; several searchs looking IOCs across different logs.&lt;/P&gt;&lt;P&gt;However, the only way I found to use the second search was using a drilldown.&lt;/P&gt;&lt;P&gt;so,&amp;nbsp;&lt;STRONG&gt;if the USER clicks&lt;/STRONG&gt; in the number (stats count - 1st query) , then the detailed information (second query) will appear in the last panel in the bottom.&amp;nbsp; As soon it appears there, then automatically the dashboard will send an email to me, but with my solution, &lt;STRONG&gt;I&amp;nbsp;am always depending on SOMEONE click in the number in red.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I could not find a way to make the drilldown works independently , meaning, drilldown be activated with second query&lt;STRONG&gt; without ANYONE clicking&lt;/STRONG&gt;, only obeying the condition bellow in the second query&amp;nbsp;&lt;/P&gt;&lt;P&gt;( &amp;lt;condition match="'click.value'!= 0"&amp;gt;)&lt;/P&gt;&lt;P&gt;Even adding a condition in drilldown I m always forced to CLICK. so annoying.&lt;/P&gt;&lt;P&gt;Then, I thought: ok, I can have the stats number, I can have the drilldown, but I could additionally add my second query again after stats number and send the email alert for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You&amp;nbsp; can take a look in my dashboard and all the code in the link below&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Splunk-dashboard-using-drilldown-showing-detailed-info-but-also/m-p/555441#M157665" target="_blank" rel="noopener"&gt;Re: Splunk dashboard using drilldown showing detai... - Splunk Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wonder if maybe the solution would be not using the drilldown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it make sense more sense to you?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 05:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556272#M157962</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-18T05:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556433#M158025</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235223"&gt;@Luciana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There seems to be some confusion.&lt;/P&gt;&lt;P&gt;I have not put ANY drilldown in my example dashboard.&amp;nbsp; It shows two panels - the first panel runs a search and shows a count. When that search finishes, it will trigger the second search.&lt;/P&gt;&lt;P&gt;Please save that example dashboard as a new dashboard and you will see how it works.&lt;/P&gt;&lt;P&gt;There is no requirement to click anything to drilldown, as the second search runs on the completion of the first search.&lt;/P&gt;&lt;P&gt;This seems to provide the solution for your problem, i.e. NO drilldown is needed to make the second search run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 23:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556433#M158025</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-20T23:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556440#M158030</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; thanks for your suggestion. I tried and&amp;nbsp; the token works perfectly I think I can adapt in my dashboard &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sorry, I got confused about the drilldown, now I understood that you had set the drilldown as 'none' &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only thing is ,&amp;nbsp;&lt;SPAN&gt;the second search will be exclusively for sending alerts with more info, s&lt;STRONG&gt;o it will not be appearing in the dashboard, Is there a way to use the same logic but now show in the dashboard?.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Luciana_0-1624237232401.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14698iFAE91D913FFC81CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Luciana_0-1624237232401.png" alt="Luciana_0-1624237232401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 01:01:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556440#M158030</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-21T01:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556445#M158033</link>
      <description>&lt;P&gt;Two ways to hide the UI for that search. Either just set&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;panel depends="$undefined$"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;in the XML for the second panel - in which case it will not show, or you can just take the whole of the&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt;
...
&amp;lt;/search&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;section from that table and put that in its own area in the XML before the first &amp;lt;row&amp;gt;&lt;/P&gt;&lt;P&gt;It will then run and is not part of any visualisation, so is never shown.&lt;/P&gt;&lt;P&gt;I find that it's often useful to use the first form, so if you want to 'debug' that query, it's easy just to define the token (in this case 'undefined') and you can then see how the search is running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 03:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556445#M158033</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-21T03:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556446#M158034</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; you helped me a lot!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Have a nice week&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 03:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556446#M158034</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-21T03:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556466#M158042</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; I understood and it worked, but in the end, I ended up showing the results from my SECOND search in the bottom panels, I've changed a little the condition match but, now is happening again what you had advised me about&lt;SPAN&gt;&amp;nbsp;once I set the token, the search will not run a second time if the first search runs again &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; and I dont know how to fix it, because I understood the issue but, I&amp;nbsp; might have not understood the logic. Would you mind to explain to me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check my code to be easier to understand:&lt;/P&gt;&lt;P&gt;&amp;lt;search id="main_search1"&amp;gt;&lt;BR /&gt;&amp;lt;query&amp;gt;index = my index sourcetype=my sourcetype action=Allowed [|inputlookup OTX | search type=URL | rename indicator as url | table url] |dedup user |stats count&amp;lt;/query&amp;gt;&lt;BR /&gt;&amp;lt;earliest&amp;gt;$time.earliest$&amp;lt;/earliest&amp;gt;&lt;BR /&gt;&amp;lt;latest&amp;gt;$time.latest$&amp;lt;/latest&amp;gt;&lt;BR /&gt;&amp;lt;refresh&amp;gt;3600s&amp;lt;/refresh&amp;gt;&lt;BR /&gt;&amp;lt;done&amp;gt;&lt;BR /&gt;&amp;lt;condition match="'result.count'!= &amp;amp;quot;0No event for this table&amp;amp;quot;"&amp;gt;&lt;BR /&gt;&amp;lt;set token="tkn_first_search"&amp;gt;index = my index sourcetype= my sourcetype action=Allowed [|inputlookup OTX | search type=URL | rename indicator as url | table url] |dedup user | table _time, url, user, serverip, ClientIP |sendemail to="myemail@domain.co.nz" server=smtp.server.co.nz subject="OTX -&amp;nbsp; Notification - IOC found by Domain" message="This is an test message" sendresults=true inline=true format=csv&amp;lt;/set&amp;gt;&lt;BR /&gt;&amp;lt;/condition&amp;gt;&lt;BR /&gt;&amp;lt;condition&amp;gt;&lt;BR /&gt;&amp;lt;unset token="tkn_first_search"&amp;gt;&amp;lt;/unset&amp;gt;&lt;BR /&gt;&amp;lt;/condition&amp;gt;&lt;BR /&gt;&amp;lt;/done&amp;gt;&lt;BR /&gt;&amp;lt;/search&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;for example, the stats count that was in RED , now has changed to green, which means there are 0 IOCs found, but the bottom panel continues to show me the oldest result&amp;nbsp;and sending me emails.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Luciana, feeling ignorant with Splunk&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 05:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556466#M158042</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-21T05:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556595#M158078</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235223"&gt;@Luciana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That code you show is not the code I suggested. In my example you see how I set the token - you should use that &amp;lt;eval&amp;gt; mechanism instead as it will always increment the token value, causing the rerun of the second search, rather than the example you are using from your similar question here in community, where you are only ever setting a constant token, so will never trigger the rerun.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 00:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556595#M158078</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-22T00:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556610#M158081</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;, How are you? First, I want to thank you for helping me.&amp;nbsp; I think there is a misunderstanding here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, the issue here is HOW to run a SECOND search IF the results in the FIRST search is =! 0, right?&lt;/P&gt;&lt;P&gt;However, in the example you gave me , &lt;STRONG&gt;you used my first search, instead of the SECOND.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;my first search is:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index = my index sourcetype= my sourcetype action=Allowed [|inputlookup OTX | search type=URL | rename indicator as url | table url] |dedup user &lt;STRONG&gt;|stats count&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but , my SECOND search is:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index = my index sourcetype= my sourcetype action=Allowed [|inputlookup OTX | search type=URL | rename indicator as url | table url] |dedup user &lt;STRONG&gt;| table _time, url, user, serverip, ClientIP |sendemail to="myemail@domain.co.nz" server=smtp.server.co.nz subject="OTX -&amp;nbsp; Notification - IOC found by Domain" message="This is an test message" sendresults=true inline=true format=csv&amp;lt;/set&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What I dont know is HOW to trigger a second search , if the results of the first one is !=0&lt;/P&gt;&lt;P&gt;You said that I should add the token in the SECOND search, which makes sense, but then, I didnt understand HOW to trigger my second search using&lt;/P&gt;&lt;P&gt;&amp;nbsp; eval token="trigger"&amp;gt;if(isnull($trigger$),0,$trigger$+1)&amp;lt;/eval&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;in your example, you used "stats count" in the 2 queries.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Luciana_0-1624334184038.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14724i203B14C849542731/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Luciana_0-1624334184038.png" alt="Luciana_0-1624334184038.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Can you clarify?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I feeling ignorant, but I cant help it. so, I tried to get the main idea.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;so, in your example,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 04:00:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556610#M158081</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-22T04:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556803#M158138</link>
      <description>&lt;P&gt;The dashboard I gave you is an example so you could see HOW it works - I don't have your data, so cannot use your search in my example - you will use YOUR queries, not mine in your version of the dashboard.&lt;/P&gt;&lt;P&gt;This is the first query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;query&amp;gt;index=_audit earliest=-1m latest=now
  | stats count
&amp;lt;/query&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Replace this query with your query.&lt;/P&gt;&lt;P&gt;The XML section&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;done&amp;gt;
  &amp;lt;condition match="$job.resultCount$&amp;amp;gt;0"&amp;gt;
    &amp;lt;eval token="trigger"&amp;gt;if(isnull($trigger$),0,$trigger$+1)&amp;lt;/eval&amp;gt;
  &amp;lt;/condition&amp;gt;
&amp;lt;/done&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;is the logic that you must use to set the token based on your condition. This is what you would need to test the field 'count' coming from your | stats count, i.e. result.count. This will increment the value of your trigger token.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;done&amp;gt;
  &amp;lt;condition match="$result.count$&amp;amp;gt;0"&amp;gt;
    &amp;lt;eval token="trigger"&amp;gt;if(isnull($trigger$),0,$trigger$+1)&amp;lt;/eval&amp;gt;
  &amp;lt;/condition&amp;gt;
&amp;lt;/done&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;In YOUR second query, you need to include the $trigger$ token as part of your SPL search. That is HOW the second search will run - you don't do anything - Splunk will detect that the $trigger$ token has changed value, so will automatically rerun the search.&lt;/P&gt;&lt;P&gt;The simplest way to include that token in your search is to include the eval statement in your SPL like below&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| dedup user
| eval _dummy=$trigger$
| table....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 04:07:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556803#M158138</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-23T04:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - How to trigger second search based on first search where condition is : first result count</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556807#M158141</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;, yes, now I understood, and it worked, thank you so much for your patience.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 05:10:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Dashboard-How-to-trigger-second-search-based-on-first-search/m-p/556807#M158141</guid>
      <dc:creator>Luciana</dc:creator>
      <dc:date>2021-06-23T05:10:15Z</dc:date>
    </item>
  </channel>
</rss>

