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>
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...