Splunk Enterprise

Dashborad 1 search have greater than and smaller than

kennethyeung
New Member

Is it possible in the dashboard text fileld,

if i input positive number , such 3, the search will query result than > 3
if i input negative number, such as -3 the search will query result smaller than <-2

I can do it in 2 search, but if can do it in 1 query or 1 dashboard, it would be great
Thanks

Tags (1)
0 Karma
1 Solution

493669
Super Champion

just made a few correction by replacing > and < by "&gt;" and "&lt;" and it works...

<form>
   <label>math</label>
   <fieldset submitButton="false">
     <input type="text" token="field1">
       <label>field1</label>
       <change>
         <condition match="'value' &lt; &quot;0&quot;">
           <set token="cond">| where value &lt; </set>
           <eval token="my_value">$value$+1</eval>
         </condition>
         <condition match="'value' &gt; &quot;0&quot;">
           <set token="cond">| where value&gt;</set>
           <set token="my_value">$value$</set>
         </condition>
         <condition>
           <set token="cond"></set>
           <set token="my_value"></set>
         </condition>
       </change>
     </input>
   </fieldset>
   <row>
     <panel>
       <table>
         <title>$cond$ $my_value$</title>
         <search>
           <query>| makeresults | eval value="-3" | append [| makeresults | eval value="-2" ] | append [| makeresults | eval value="-1" ] | append [| makeresults | eval value="0" ] | append [| makeresults | eval value="2" ] | append [| makeresults | eval value="3" ] | append [| makeresults | eval value="4" ] $cond$ $my_value$  </query>
           <earliest>-24h@h</earliest>
           <latest>now</latest>
           <sampleRatio>1</sampleRatio>
         </search>
         <option name="count">50</option>
         <option name="dataOverlayMode">none</option>
         <option name="drilldown">none</option>
         <option name="percentagesRow">false</option>
         <option name="rowNumbers">false</option>
         <option name="totalsRow">false</option>
         <option name="wrap">true</option>
       </table>
     </panel>
   </row>
  </form>

View solution in original post

0 Karma

493669
Super Champion

just made a few correction by replacing > and < by "&gt;" and "&lt;" and it works...

<form>
   <label>math</label>
   <fieldset submitButton="false">
     <input type="text" token="field1">
       <label>field1</label>
       <change>
         <condition match="'value' &lt; &quot;0&quot;">
           <set token="cond">| where value &lt; </set>
           <eval token="my_value">$value$+1</eval>
         </condition>
         <condition match="'value' &gt; &quot;0&quot;">
           <set token="cond">| where value&gt;</set>
           <set token="my_value">$value$</set>
         </condition>
         <condition>
           <set token="cond"></set>
           <set token="my_value"></set>
         </condition>
       </change>
     </input>
   </fieldset>
   <row>
     <panel>
       <table>
         <title>$cond$ $my_value$</title>
         <search>
           <query>| makeresults | eval value="-3" | append [| makeresults | eval value="-2" ] | append [| makeresults | eval value="-1" ] | append [| makeresults | eval value="0" ] | append [| makeresults | eval value="2" ] | append [| makeresults | eval value="3" ] | append [| makeresults | eval value="4" ] $cond$ $my_value$  </query>
           <earliest>-24h@h</earliest>
           <latest>now</latest>
           <sampleRatio>1</sampleRatio>
         </search>
         <option name="count">50</option>
         <option name="dataOverlayMode">none</option>
         <option name="drilldown">none</option>
         <option name="percentagesRow">false</option>
         <option name="rowNumbers">false</option>
         <option name="totalsRow">false</option>
         <option name="wrap">true</option>
       </table>
     </panel>
   </row>
  </form>
0 Karma

kennethyeung
New Member

Thanks it worked on negative number but not positive number

0 Karma

493669
Super Champion

already updated ...please check for +ve numbers

0 Karma

kennethyeung
New Member

Thanks you you and @kamlesh_vaghela
i learn how to use conditional match.

0 Karma

493669
Super Champion
<condition match="'value' &gt; &quot;0&quot;">
            <set token="cond">| where value&gt;</set>
            <set token="my_value">$value$</set>
          </condition>
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @kennethyeung,

I tried your requirement in below dashboard xml. Can you please try this? Take note I've used makeresults in search for sample events.

<form>
  <label>Dashborad 1</label>
  <fieldset submitButton="false">
    <input type="text" token="field1">
      <label>field1</label>
      <change>
        <condition match="'value' < &quot;0&quot;">
          <set token="cond">| where value <</set>
          <eval token="my_value">$value$+1</eval>
        </condition>
        <condition match="'value' > &quot;0&quot;">
          <set token="cond">| where value></set>
          <set token="my_value">$value$</set>
        </condition>
        <condition>
          <set token="cond"></set>
          <set token="my_value"></set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>$cond$ $my_value$</title>
        <search>
          <query>| makeresults | eval value="-3" | append [| makeresults | eval value="-2" ] | append [| makeresults | eval value="-1" ] | append [| makeresults | eval value="0" ] | append [| makeresults | eval value="2" ] | append [| makeresults | eval value="3" ] | append [| makeresults | eval value="4" ] $cond$ $my_value$  </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">50</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>

Thanks

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...