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
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...