Archive

Related to tokens in multiselect

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>
Tags (1)
1 Solution

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

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

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

0 Karma

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

0 Karma

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

0 Karma

SplunkTrust
SplunkTrust

Have you tried this?

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

yes i tried this

0 Karma

Hi kamlesh ji.
give me any solution for this

0 Karma

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

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

0 Karma

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

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

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());
    });
0 Karma

SplunkTrust
SplunkTrust

@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