Splunk Search

text box input for decimal numbers

mqueddeng
Engager

Hi there,

I have a text box input (SearchTextSetting module) where users can enter in a number, which is then used for calculations in HiddenSearch & HiddenPostProcess.
The problem I have is that, it only seems to recognize the digits before a decimal point. ie. if user enters 2.50 then when I print it's value to table, it displays as 2.

I attach code snippet below, where SearchTextSetting input is used to set $baseload$.
When I use whole numbers, the calculations work out fine, but I would like it to also work properly when decimal numbers are entered.

...
         <module name="HiddenSearch" autoRun="False">
          <param name="search">index=perf sourcetype=snmp | bucket _time span=1m | stats avg(dpStatusSystemUsageLoad) as "AvgLoad" by host,_time | eval BaseLoad=$baseload$</param>
          <module name="SearchTextSetting" layoutPanel="panel_row1_col3" autoRun="False">
              <param name="elementName">baseload_element</param>
              <param name="settingName">baseload_setting</param>
              <param name="label">Key in baseload ie. System Usageload when no transactions are running (use 2 if unknown)</param>
              <module name="ConvertToIntention">
                <param name="settingToConvert">baseload_setting</param>
                <param name="intention">
                  <param name="name">stringreplace</param>
                  <param name="arg">
                    <param name="baseload">
                      <param name="fillOnEmpty">True</param>
                      <param name="value">$target$</param>
                    </param>
                  </param>
                </param>
                <module name="HiddenPostProcess" layoutPanel="panel_row3_col1">
                  <param name="search">table _time,AvgLoad,BaseLoad</param>
                  <module name="JobProgressIndicator">
                    <module name="EnablePreview">
                      <param name="enable">True</param>
                      <param name="display">False</param>
                      <module name="SimpleResultsTable">
                        <param name="drilldown">row</param>
                        <param name="count">20</param>
                      </module>
                    </module><!-- EnablePreview -->
                  </module><!-- JobProgressIndicator -->
                </module><!-- HiddenPostProcess -->
              ...
0 Karma

mqueddeng
Engager

ok after some unsuccessful attempts at using addterm instead of stringreplace (for which I found documentation lacking..), I got it working by using tonumber function

ie. before fix:
index=perf sourcetype=snmp | bucket _time span=1m | stats avg(dpStatusSystemUsageLoad) as "AvgLoad" by host,_time | eval BaseLoad=$baseload$

after fix:
index=perf sourcetype=snmp | bucket _time span=1m | stats avg(dpStatusSystemUsageLoad) as "AvgLoad" by host,_time | eval BaseLoad=tonumber("$baseload$",10)

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...