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

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...