Dashboards & Visualizations

Dashboard text input - accepting null and escaping back slashes

PleaseHelp
New Member

Hi, 

My dashboard has a few text boxes and I'm trying to make the inputs as user friendly as possible.

I came across multiple issues which I have solved with previous posts however, there is a conflict with the solutions that prevent me from implementing both at the same time. 


#1 - If a text input is empty then that field should be ignored in the search. This can be fixed by adding a prefix and suffix 

Ideally we can also input partial paths so there is also an implicit * character. 

    <input type="text" token="Get_Process_Path">
      <label>Process Name or Path</label>
      <prefix>process_path="*</prefix>
      <suffix>*"</suffix>
    </input>


https://community.splunk.com/t5/Dashboards-Visualizations/Evaluating-form-field-if-not-null/td-p/181... 

 

#2 - Interpret back slash characters as text so we don't need to manually add \\ to every path. The |s filter for tokens fixed this. 

process_path=$Get_Process_Path|s$


https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-escape-backslashes-in-user-inpu... 

 

I can get both of these working on their own but not at the same time. Is there a way to do this or do I need a different approach? 

Thanks.

Labels (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Why are you using 

proces_path=$Get_Process_Path|s$

if $Get_Process_Path$ already has the process_path="* prefix? Is this what is causing the issue?

0 Karma

PleaseHelp
New Member

Hi, 

I have tried this without the proces_path= assignment since that is in the prefix, so just $Get_Process_Path|s$

Here is a snippet: 

<input type="text" token="Get_Process_Path">
<label>Process Name or Path</label>
<prefix>process_path="*</prefix>
<suffix>*"</suffix>
</input>

<query>index=windows EventCode=4688
$Get_Process_Path|s$


This will break the search, I believe it's because |s is wrapping additional quotes around what is in the prefix. 

But I need both of those things to fix the individual issues. 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

See this example dashboard - this uses a <change> block on the input to change the token

<form version="1.1" theme="light">
  <label>Backslash escaped input</label>
  <fieldset submitButton="false">
    <input type="text" token="Get_Process_Path" searchWhenChanged="true">
      <label>Enter Path</label>
      <prefix>process_path="*</prefix>
      <suffix>*"</suffix>
      <change>
        <eval token="escaped_path">replace($Get_Process_Path$, "\\\\", "\\\\")</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>Token created from the user's input is <b style="color:blue">[$Get_Process_Path$]</b> and the up[dated search token applied is <b style="color:red">[$escaped_path$]</b></html>
      <table>
        <search>
          <query>index=_audit $escaped_path$</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>
        </search>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
</form>
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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...