Dashboards & Visualizations

Related to tokens in multiselect

harishalipaka
Motivator

Hi all,
I want multisections tokens.when user select All than one token will generate else anothe token generate for multiselectin also..
i tried like this plas help to me ..

 <input type="multiselect" token="sourcetype_zone" searchWhenChanged="true">
      <label>Zone</label>

      <!-- The final value will be surrounded by prefix and suffix -->
      <prefix>(</prefix>
      <suffix>)</suffix>
      <!-- Each value will be surrounded by the valuePrefix and valueSuffix -->
      <valuePrefix>zone like "</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <!-- All the values and their valuePrefix and valueSuffix will be concatenated together with the delimiter between them -->
      <delimiter> OR </delimiter>
    <default>ALL</default>
    <choice value="%">ALL</choice>
    <choice value="East1">East1</choice>    
    <choice value="East2">East2</choice>    
    <choice value="West1">West1</choice>    
    <choice value="West2">West2</choice>    
             <change>
           <condition match='value ="%"'>
             <set token="zoneall"></set>              
               <unset token="zonesingle"></unset>
           </condition>
           <condition  match='value !="%"'>
             <set token="zonesingle"></set>              
               <unset token="zoneall"></unset>
           </condition>
     </change>


    </input>
Thanks
Harish
Tags (1)
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

HI @harishalipaka,

Can you please try this?

Related to tokens in multiselect

<input type="multiselect" token="sourcetype_zone" searchWhenChanged="true">
   <label>Zone</label>

   <!-- The final value will be surrounded by prefix and suffix -->
   <prefix>(</prefix>
   <suffix>)</suffix>
   <!-- Each value will be surrounded by the valuePrefix and valueSuffix -->
   <valuePrefix>zone like "</valuePrefix>
   <valueSuffix>"</valueSuffix>
   <!-- All the values and their valuePrefix and valueSuffix will be concatenated together with the delimiter between them -->
   <delimiter> OR </delimiter>
 <default>ALL</default>
 <choice value="%">ALL</choice>
 <choice value="East1">East1</choice>    
 <choice value="East2">East2</choice>    
 <choice value="West1">West1</choice>    
 <choice value="West2">West2</choice>    
  <change>
    <condition value="%">
      <set token="zoneall">True</set>              
        <unset token="zonesingle"></unset>
      </condition>
      <condition>
        <set token="zonesingle">True</set>              
        <unset token="zoneall"></unset>
      </condition>
  </change>
 </input>

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

HI @harishalipaka,

Can you please try this?

Related to tokens in multiselect

<input type="multiselect" token="sourcetype_zone" searchWhenChanged="true">
   <label>Zone</label>

   <!-- The final value will be surrounded by prefix and suffix -->
   <prefix>(</prefix>
   <suffix>)</suffix>
   <!-- Each value will be surrounded by the valuePrefix and valueSuffix -->
   <valuePrefix>zone like "</valuePrefix>
   <valueSuffix>"</valueSuffix>
   <!-- All the values and their valuePrefix and valueSuffix will be concatenated together with the delimiter between them -->
   <delimiter> OR </delimiter>
 <default>ALL</default>
 <choice value="%">ALL</choice>
 <choice value="East1">East1</choice>    
 <choice value="East2">East2</choice>    
 <choice value="West1">West1</choice>    
 <choice value="West2">West2</choice>    
  <change>
    <condition value="%">
      <set token="zoneall">True</set>              
        <unset token="zonesingle"></unset>
      </condition>
      <condition>
        <set token="zonesingle">True</set>              
        <unset token="zoneall"></unset>
      </condition>
  </change>
 </input>

harishalipaka
Motivator

Hi kamlesh it is working fine in desktop only.
it is not working in mobiles..
please tell me the prolem if you know

Thanks
Harish
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

HI @harishalipaka,
Can you please let me know how behaving multiselect on mobile?
Is Token is not set as per expected?

0 Karma

harishalipaka
Motivator
0 Karma

harishalipaka
Motivator

and i tried like this also
condition match="value = "%""
condition match="len($sourcetype_zone$)!=1"

Thanks
Harish
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Have you tried this?

<condition match=" match($value$,&quot;%&quot;)">
0 Karma

harishalipaka
Motivator

yes i tried this

Thanks
Harish
0 Karma

harishalipaka
Motivator

Hi kamlesh ji.
give me any solution for this

Thanks
Harish
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

HI @harishalipaka,

I'm doing some workaround. Let me try something different which will work on both Desktop as well as Mobile.

Thanks

0 Karma

harishalipaka
Motivator

ya am trying like that but am not getting,
ok try this when you are free

Thanks
Harish
0 Karma

harishalipaka
Motivator
<change>    See change  Not available for multiselect inputs.
<condition> See condition (input)   Not available for multiselect inputs.
Thanks
Harish
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

ooh. That might be the reason for not working in mobile. Technically It should not work for desktop also.
What you think about to set token using javascript? Have you tried it ever?

0 Karma

harishalipaka
Motivator

require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc) {
// Access the "default" token model
var defaultTokenModel = mvc.Components.get('default');
var submittedTokens = mvc.Components.get('submitted');

    var tokens = mvc.Components.get("default");
    var tokenValue = tokens.get("token1");
    tokens.set("selection1", "zone");    
    tokens.set("selection2", "zone");
    tokens.set("selection3", "zone");   
    submittedTokens.set(defaultTokenModel.toJSON());

    var sourcetype_zone_id = mvc.Components.get('sourcetype_zone_id');

    sourcetype_zone_id.on('change', function(value) {
        var location= document.getElementById("sourcetype_location_id").children[1].children[1].value;       

        if(value.length!=0) {
            if(value=="%" && location =="%") {
                var tokens = mvc.Components.get("default");
                var tokenValue = tokens.get("token1");
                tokens.set("selection1", "zone");
                tokens.set("selection2", "zone");
                tokens.set("selection3", "zone");      
            } else if(value !=="%" && location =="%") {
                var tokens = mvc.Components.get("default");
                var tokenValue = tokens.get("token1");
                tokens.set("selection1", "port");
                tokens.set("selection2", "port");
                tokens.set("selection3", "port");            
            }
        } else {
            var tokens = mvc.Components.get("default");
            var tokenValue = tokens.get("token1");
            tokens.set("selection1", "vesselid vesselname");
            tokens.set("selection2", "vesselid");  
            tokens.set("selection3", "vesselid&vesselname");        
        }

        submittedTokens.set(defaultTokenModel.toJSON());
    });
Thanks
Harish
0 Karma

niketn
Legend

@harishalipaka, your requirement is not quite clear but if it is to add all field value search, most of the examples in Splunk Docs and Splunk Dashboard Examples App use static input choice for All as asterisk (*) in the input to ensure that wildcard search for all events is performed.

  <choice value="*">All</choice>

Try the following run anywhere dashboard

<form>
  <label>All Search</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokSourceType" searchWhenChanged="true">
      <label>Select Sourcetype</label>
      <choice value="*">All</choice>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
      <search>
        <query>|  tstats count where index="_internal" by sourcetype 
|  sort sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>index=_internal sourcetype="$tokSourceType$"
          | stats count by sourcetype
          | sort - count
          </query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
      </table>
    </panel>
  </row>
</form>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...