Dashboards & Visualizations

makeresult token

surekhasplunk
Communicator

I am making 5 tokens using below query :

     <search>
        <query>|makeresults |index=capaplan_wan_ibfs InOut="in"
    | eval Device_Interface = orig_host . ":" . Interface 
    | fields - orig_host Interface 
    | table Device_Interface  LoadDuration 
    | rex field=Device_Interface "^(?&lt;Device&gt;.*?):(?&lt;Interface&gt;.*)$" 
    | fields - Device_Interface | dedup Device | sort -LoadDuration | head 5 | table Device| transpose | rename "row 1" as device1  "row 2" as device2  "row 3" as device3  "row 4" as device4  "row 5" as device5
         </query>
        <earliest>-3mon</earliest>
        <latest>now</latest>
        <done>
          <set token="tokDevice1">$result.device1$</set>
          <set token="tokDevice2">$result.device2$</set>
          <set token="tokDevice3">$result.device3$</set>
          <set token="tokDevice4">$result.device4$</set>
          <set token="tokDevice5">$result.device5$</set>
        </done>
       </search>

Now i want to use these tokens in my next panel query as input like

| mstats max(_value) as "Bits_in_sec" WHERE (metric_name="*in" ) AND (host=$tokDevice1$) by host

But its not getting the input i.e. the token vaule is not getting passed. Pleasehelp

Tags (2)
0 Karma
1 Solution

DavidHourani
Super Champion

Hi @surekhasplunk,

Your search seems to be broken because you are using two generating clause in a row. Please remove makeresults as follows :

  <query>index=capaplan_wan_ibfs InOut="in"
 | eval Device_Interface = orig_host . ":" . Interface 
 | fields - orig_host Interface 
 | table Device_Interface  LoadDuration 
 | rex field=Device_Interface "^(?<Device>.*?):(?<Interface>.*)$" 
 | fields - Device_Interface | dedup Device | sort -LoadDuration | head 5 | table Device| transpose | rename "row 1" as device1  "row 2" as device2  "row 3" as device3  "row 4" as device4  "row 5" as device5
  </query>

Or if you really need to keep the results from makeresults for some reason then you will need to use append:

  <query>|makeresults |append [|index=capaplan_wan_ibfs InOut="in"]
 | eval Device_Interface = orig_host . ":" . Interface 
 | fields - orig_host Interface 
 | table Device_Interface  LoadDuration 
 | rex field=Device_Interface "^(?<Device>.*?):(?<Interface>.*)$" 
 | fields - Device_Interface | dedup Device | sort -LoadDuration | head 5 | table Device| transpose | rename "row 1" as device1  "row 2" as device2  "row 3" as device3  "row 4" as device4  "row 5" as device5
 </query>

Cheers,
David

View solution in original post

0 Karma

DavidHourani
Super Champion

Hi @surekhasplunk,

Your search seems to be broken because you are using two generating clause in a row. Please remove makeresults as follows :

  <query>index=capaplan_wan_ibfs InOut="in"
 | eval Device_Interface = orig_host . ":" . Interface 
 | fields - orig_host Interface 
 | table Device_Interface  LoadDuration 
 | rex field=Device_Interface "^(?<Device>.*?):(?<Interface>.*)$" 
 | fields - Device_Interface | dedup Device | sort -LoadDuration | head 5 | table Device| transpose | rename "row 1" as device1  "row 2" as device2  "row 3" as device3  "row 4" as device4  "row 5" as device5
  </query>

Or if you really need to keep the results from makeresults for some reason then you will need to use append:

  <query>|makeresults |append [|index=capaplan_wan_ibfs InOut="in"]
 | eval Device_Interface = orig_host . ":" . Interface 
 | fields - orig_host Interface 
 | table Device_Interface  LoadDuration 
 | rex field=Device_Interface "^(?<Device>.*?):(?<Interface>.*)$" 
 | fields - Device_Interface | dedup Device | sort -LoadDuration | head 5 | table Device| transpose | rename "row 1" as device1  "row 2" as device2  "row 3" as device3  "row 4" as device4  "row 5" as device5
 </query>

Cheers,
David

0 Karma

renjith_nair
Legend

@surekhasplunk, kindly use the formatting (code sample) for readability.

What's the use of makeresults in your search? Are you getting result for your search in your panel?

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

surekhasplunk
Communicator

Hi @renjith.nair ,

The use of makeresult is to get the top 5 devices and set them with a token value so that i can use it in my other panel query. And i want to keep the query result hidden as well. so using makeresults

0 Karma

renjith_nair
Legend

@surekhasplunk, you dont need makeresults and more over the search will throw an error.
Try executing the search in a search window and see what you get.
Just remove the |makeresults from your search and you should be getting the token set.

https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Makeresults

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...