<?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 enable  Annotation based on token value. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403268#M173697</link>
    <description>&lt;P&gt;@agoyal one crude way would be to add token dependency to &lt;CODE&gt;annotation&lt;/CODE&gt; search so that it does not run when the token is not set. However, doing so, Splunk UI will show a warning message that Annotation Search is waiting for input. You can use jQuery to hide this warning based on text.&lt;/P&gt;

&lt;P&gt;Refer to the following answer where I have used &lt;CODE&gt;comment()&lt;/CODE&gt; macro to add token dependency to a search without impacting search performance: &lt;A href="https://answers.splunk.com/answers/683826/how-do-you-set-the-order-of-queries-to-be-run-in-a.html"&gt;https://answers.splunk.com/answers/683826/how-do-you-set-the-order-of-queries-to-be-run-in-a.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Please try out and confirm if this would work!&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jan 2019 11:04:31 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-01-12T11:04:31Z</dc:date>
    <item>
      <title>how to enable  Annotation based on token value.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403267#M173696</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am using event Annotation on  timechart. but I want to  activate only in case of specific services/ based on some token value. &lt;/P&gt;

&lt;P&gt;Is there a way to enable/disable annotation based on token value ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 16:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403267#M173696</guid>
      <dc:creator>AKG1_old1</dc:creator>
      <dc:date>2019-01-11T16:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to enable  Annotation based on token value.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403268#M173697</link>
      <description>&lt;P&gt;@agoyal one crude way would be to add token dependency to &lt;CODE&gt;annotation&lt;/CODE&gt; search so that it does not run when the token is not set. However, doing so, Splunk UI will show a warning message that Annotation Search is waiting for input. You can use jQuery to hide this warning based on text.&lt;/P&gt;

&lt;P&gt;Refer to the following answer where I have used &lt;CODE&gt;comment()&lt;/CODE&gt; macro to add token dependency to a search without impacting search performance: &lt;A href="https://answers.splunk.com/answers/683826/how-do-you-set-the-order-of-queries-to-be-run-in-a.html"&gt;https://answers.splunk.com/answers/683826/how-do-you-set-the-order-of-queries-to-be-run-in-a.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Please try out and confirm if this would work!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 11:04:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403268#M173697</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-12T11:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to enable  Annotation based on token value.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403269#M173698</link>
      <description>&lt;P&gt;@niketnilay answered this one, but you can extend his suggestion so that you don't get any errors.  &lt;/P&gt;

&lt;P&gt;There are at least four ways.  &lt;/P&gt;

&lt;P&gt;A) You can use the selected service name to build different SPL for the annotation search inside a second token.&lt;/P&gt;

&lt;P&gt;B) You can use the selected service to put the name of a different annotation base search into a token that will load your panel... and have one empty search for the purpose of loading "no" events.&lt;/P&gt;

&lt;P&gt;C) You can build two different panels, one with the annotation search and one without, and use a token with depends/rejects to decide which panel to show.&lt;/P&gt;

&lt;P&gt;D) You can set your annotation search itself up so that it returns no events when you don't want any annotations, and avoid all the above overhead.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;A) You can use the selected service name to build different SPL for the annotation search inside a second token.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="tok_service"&amp;gt;
  &amp;lt;label&amp;gt;Select a Service&amp;lt;/label&amp;gt;
  &amp;lt;search base="myservices"&amp;gt;
    &amp;lt;query /&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;service&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;service&amp;lt;/fieldForValue&amp;gt;

  &amp;lt;change&amp;gt;
    &amp;lt;condition match=" $tok_service$ == &amp;amp;quot;ServiceName1&amp;amp;quot; "&amp;gt;
          &amp;lt;set token="myannotationSPL"&amp;gt;The SPL you want for Service Name 1 &amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt; 
    &amp;lt;condition&amp;gt;  
            &amp;lt;set token="myannotationSPL"&amp;gt;The default SPL you want&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt; 
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;B) You can use the selected service to put the name of the base search into a token that will load your panel... and have one empty search for the purpose of loading "no" events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search id="BaseSearchName1"&amp;gt;
  &amp;lt;query&amp;gt;
      The SPL you want for Service Name 1 
  &amp;lt;/query&amp;gt;
  &amp;lt;earliest&amp;gt;&amp;lt;/earliest&amp;gt;
  &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
&amp;lt;/search&amp;gt;

&amp;lt;search id="BaseSearchName2"&amp;gt;
   &amp;lt;query&amp;gt;
      The default SPL you want
   &amp;lt;/query&amp;gt;
  &amp;lt;earliest&amp;gt;&amp;lt;/earliest&amp;gt;
  &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
&amp;lt;/search&amp;gt;


&amp;lt;input type="dropdown" token="tok_service"&amp;gt;
  &amp;lt;label&amp;gt;Select a Service&amp;lt;/label&amp;gt;
  &amp;lt;search base="myservices"&amp;gt;
    &amp;lt;query /&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;service&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;service&amp;lt;/fieldForValue&amp;gt;

  &amp;lt;change&amp;gt;
    &amp;lt;condition match=" $tok_service$ == &amp;amp;quot;ServiceName1&amp;amp;quot; "&amp;gt;
          &amp;lt;set token="annotationBase"&amp;gt;BaseSearchName1&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt; 
    &amp;lt;condition&amp;gt;  
          &amp;lt;set token="annotationBase"&amp;gt;BaseSearchName2&amp;lt;/set&amp;gt;
    &amp;lt;/condition&amp;gt; 
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;C) you can build two different panels, one with the annotation search and one without, and use a token with depends/rejects to decide which one to show.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;D) You can set your annotation search itself up so that it returns no events when you don't want any annotations, and avoid all the above overhead.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 21:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-enable-Annotation-based-on-token-value/m-p/403269#M173698</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-23T21:49:09Z</dc:date>
    </item>
  </channel>
</rss>

