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.

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 ...