Dashboards & Visualizations
Highlighted

How to initialize a token value

Explorer

Hello all,
I want to initialize a token value. That is while dashboard is opened that value should be initialized to the token. I have tried writing the token value inside "init". I want to compute the token value in the "init" method, i tried and there is no change. How can i achieve this?

Tags (3)
0 Karma
Highlighted

Re: How to initialize a token value

Champion

Hi

Check this

<dashboard>
  <label>init</label>
  <init>
    <eval token="temp">1+2</eval>
  </init>
  <row>
    <html>
      $temp$
    </html>
  </row>
</dashboard>

Please post your xml.

[updated]

Try by getting the max number in query and set it in a token.

<dashboard>
   <label>max number</label>
   <search>
     <query>
       | makeresults 
 | eval temp="12,33,444,66" 
 | makemv delim="," temp 
 | stats max(temp) as num

     </query>
     <done>
       <set token="max_num">$result.num$</set>
     </done>
   </search>
   <row>
     <html>
       maximum number: $max_num$
     </html>
   </row>
 </dashboard>

View solution in original post

Highlighted

Re: How to initialize a token value

Explorer

hi @vnravikumar , thanks for answering. Is there any way to use max function in the init block?

i have a field called "num" in my file. I want to use the largest number as token.

 <eval token="temp">max(num)</eval>

can i modify my code like this?

0 Karma
Highlighted

Re: How to initialize a token value

Champion

From where are you getting the num field?

0 Karma
Highlighted

Re: How to initialize a token value

Explorer

The field "num" is in my json file.

0 Karma
Highlighted

Re: How to initialize a token value

Champion

Can you brief your requirement, whether the json data is indexed?

0 Karma
Highlighted

Re: How to initialize a token value

Explorer

I want to use the largest value of "num" field of json file as token. As the data is dynamic the largest value may change accordingly. Yes the json data is indexed.
Is there any way to achieve this?

0 Karma
Highlighted

Re: How to initialize a token value

Champion

Hi

Try by getting the max number in query and set it in a token.

<dashboard>
  <label>max number</label>
  <search>
    <query>
      | makeresults 
| eval temp="12,33,444,66" 
| makemv delim="," temp 
| stats max(temp) as num

    </query>
    <done>
      <set token="max_num">$result.num$</set>
    </done>
  </search>
  <row>
    <html>
      maximum number: $max_num$
    </html>
  </row>
</dashboard>
0 Karma
Highlighted

Re: How to initialize a token value

Explorer

Thank you! I'll try this and let you know.

0 Karma
Highlighted

Re: How to initialize a token value

Explorer

hi @vnravikumar , i tried using your code , thank you so much it is working!

0 Karma
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.