Splunk Search

How to set a field as the token to use in a dashboard?

surekhasplunk
Communicator

I have a search which will return me field email id.

index=snow description=*CPU*  |table number sys_created_by

number    sys_created_by
1234      abcd@bcd.com

Now i want to use sys_created_by field as the token to populate my dashboard

How to do this?

index=snow description=*CPU*  |where sys_created_by=$token$
1 Solution

nfilippi_splunk
Splunk Employee
Splunk Employee

You can use the search event handler to dynamically set a token based on the result. Note that the search event handler only tokenizes the first result, which looks like it should work for you.

Here's what it would look like:

<dashboard>
  <label>Test Token</label>

  <search>
    <query>index=snow description=CPU | table number sys_created_by</query>
    <earliest>-60m@m</earliest>
    <latest>now</latest>
    <done>
      <set token="sys_created_by">$result.sys_created_by$</set>
    </done>
  </search>

  <row>
    <panel>
      <table>
        <search>
          <query>index=snow description=CPU sys_created_by=$sys_created_by$</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>       
        </search>
      </table>
    </panel>
  </row>
</dashboard>

View solution in original post

nfilippi_splunk
Splunk Employee
Splunk Employee

You can use the search event handler to dynamically set a token based on the result. Note that the search event handler only tokenizes the first result, which looks like it should work for you.

Here's what it would look like:

<dashboard>
  <label>Test Token</label>

  <search>
    <query>index=snow description=CPU | table number sys_created_by</query>
    <earliest>-60m@m</earliest>
    <latest>now</latest>
    <done>
      <set token="sys_created_by">$result.sys_created_by$</set>
    </done>
  </search>

  <row>
    <panel>
      <table>
        <search>
          <query>index=snow description=CPU sys_created_by=$sys_created_by$</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>       
        </search>
      </table>
    </panel>
  </row>
</dashboard>

inventsekar
SplunkTrust
SplunkTrust

You can use the token directly inside the query.

  index=snow description=CPU |table number $token$
0 Karma

surekhasplunk
Communicator

Thanks but how do I set the token to sys_created_by field first.
As after setting the token only I can use it like $token$

0 Karma

rodrigorsilva
Communicator

Hi,

Try to check the link below:

http://docs.splunk.com/Documentation/Splunk/6.5.0/Viz/tokens

tks

Rodrigo Ribeiro

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...