Splunk Search

setting some token based on the result of search query

AKG1_old1
Builder

Hi,

My requirement is to set some token based on the output of search query. my search query return one row and I want to use output of one field as condition.

<search>
    <query>base search | table ID, Host, Log_or_Live </query>
    <done>
        <condition match="$result.Log_or_Live$ == log">
    set some token
          </condition> 
        <condition match="$result.Log_or_Live$ == live">
    set some token
          </condition> 
    <done>
</search>

Thanks

1 Solution

rjthibod
Champion

What you are trying to do should work, but there are some syntax issues you should address.

Try this where you use single quotes instead of the dollar signs around Log_or_Live and you use the html double quote entity &quot; around the matching string values.

 <search>
     <query>base search | table ID, Host, Log_or_Live </query>
     <done>
         <condition match="'result.Log_or_Live' == &quot;log&quot;">
     set some token
           </condition> 
         <condition match="'result.Log_or_Live' == &quot;live&quot;">
     set some token
           </condition> 
     <done>
 </search>

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi
Can you please try this?

<search>
      <query>base search | table ID, Host, Log_or_Live </query>
      <done>
          <condition match="match('result.Log_or_Live',&quot;log&quot;)">
      set some token
            </condition> 
          <condition match="match('result.Log_or_Live',&quot;live&quot;)">
      set some token
            </condition> 
      <done>
  </search>

Thanks

AKG1_old1
Builder

This is working as well. 🙂

rjthibod
Champion

What you are trying to do should work, but there are some syntax issues you should address.

Try this where you use single quotes instead of the dollar signs around Log_or_Live and you use the html double quote entity &quot; around the matching string values.

 <search>
     <query>base search | table ID, Host, Log_or_Live </query>
     <done>
         <condition match="'result.Log_or_Live' == &quot;log&quot;">
     set some token
           </condition> 
         <condition match="'result.Log_or_Live' == &quot;live&quot;">
     set some token
           </condition> 
     <done>
 </search>
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...