Splunk Search

Is it possible to modify a form token's value after it is selected?

vinay4444
Explorer

HI currently i am calling a splunk report with a parameter like below. Host is like ServerName.DatabaseName

<a href="http://XXXXX/en-US/app/search/database_monitoring_storage_02?form.Host=$Host$" class="btn btn-primary">Storage</a>

i want to include just ServerName in $Host$ while i call above how can i change this?

Tags (1)
0 Karma

somesoni2
Revered Legend

Try something like this for dropdown xml. The populating search for the dropdown with have two fields, one with servername and database (to be used as label) and one with servername only (to be used as value). Then `` element will define two new tokens from the label and value of the dropdown. Use the $HostName$ wherever you need both servername and database and use $Host$ where you need just the server name.

<fieldset submitButton="false">
   <input type="dropdown" token="host_tok" searchWhenChanged="true">
      <label>Host</label>
      <search>
        <query>
          Your query giving two fields  servernameWdatabase and  servernameOnly
        </query>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </search>
      <fieldForLabel>servernameWdatabase</fieldForLabel>
      <fieldForValue>servernameOnly</fieldForValue>

      <change>
          <set token="HostName">$label$</set>
          <set token="Host">$value$</set>
      </change>      
    </input>
  </fieldset>

woodcock
Esteemed Legend

You can do it like this:

| noop | stats count AS HostFirstPart | eval junk=$Host$ | rex field=junk "(?<HostFirstPart>[^\.]+)" | map search="Put Your Real Search Here But Use $HostFirstPart$ Instead Of $Host$"
0 Karma

vinay4444
Explorer

i want a way to have one part of token to be put in html area ( NOT SEARCH )

Storage

I am using above code in button that calls another dashboard

0 Karma

vinay4444
Explorer

I want to use $HostFirstPart$ in XML when i call another dashboard with token not in search :

Storage

0 Karma

woodcock
Esteemed Legend

I have no idea what your last comment means.

0 Karma

vinay4444
Explorer

Hi this is from input ( drop down)

0 Karma

somesoni2
Revered Legend

You can update the search that populates the dropdown to create another field with just the Server Name and Use the new field as "fieldforvalue". THis way the token $Host$ will have value as Server Name only.

0 Karma

vinay4444
Explorer

but i am using $host$ in other charts where it needs servername.database name format only. only one place where i call another report (via button) i need servername alone.

0 Karma

somesoni2
Revered Legend

From where are you getting the values for the $Host$ token? A search result OR form input?

0 Karma
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...