Dashboards & Visualizations

How to use inputlookup output as parameter in streaming command?

wazuhtest
Explorer

I have only one KVstore row for storing session data, and I need that fields as arguments for streaming commands along the whole app. Example:

I have one row (I only need one) with session data here:

| inputlookup kvstore_lookup | table baseip ,baseport,ipapi,portapi,userapi,passapi |

And I would need to use those fields as arguments in the following streaming command search:

| getmanagerlogs $baseip$ $baseport$ $ipapi$ $portapi$ $userapi$ $passapi$  | table timestamp, tag, level, description |

What I tried to do is the following:
- First of all, in the dashboard,I bring kvstore_lookup data via http with $ajax, and set the token values in the callback like this:

$(document).ready(function(){
             service.request(
                 "storage/collections/data/credentials/",
                 "GET",
                 null,
                 null,
                 null,
                 {"Content-Type": "application/json"},null
             ).done(function(data) { 
                 console.log(data)
                 setToken('baseip',data[0].baseip);
                 setToken('baseport',data[0].baseport);
                 setToken('ipapi',data[0].ipapi);
                 setToken('portapi',data[0].portapi);
                 setToken('userapi',data[0].userapi);
                 setToken('passwordapi',data[0].passwordapi);
            });
         });

But it seems like the search is loaded before that callback is invoked:

var search1 = new SearchManager({
          "id": "search1",
          "search": "| getmanagerlogs $baseip$ $baseport$ $ipapi$ $portapi$ $userapi$ $passwordapi$ | table timestamp, tag, level, description | search  level=$value$",
          "status_buckets": 0,
          "earliest_time": "-24h@h",
          "cancelOnUnload": true,
          "sample_ratio": null,
          "latest_time": "now",
          "app": utils.getCurrentApp(),
          "auto_cancel": 90,
          "preview": true,
          "tokenDependencies": {
          },
          "runWhenTimeIsUndefined": false
        }, { tokens: true, tokenNamespace: "submitted" });

I thought something about crossing or joining both queries, but I wasn't able to make it work also.
Any help will be much appreciated.

0 Karma

DalJeanis
Legend

First, what happens when you fill in this search with the values and run it?

| getmanagerlogs $baseip$ $baseport$ $ipapi$ $portapi$ $userapi$ $passwordapi$ 
| table timestamp, tag, level, description 
| search  level=$value$

Second, are the values in $baseip$ (for example) supposed to be formatted as 1.1.1.1 OR as baseip=1.1.1.1

0 Karma

wazuhtest
Explorer

@DalJeanis It works perfectly when I 'hardcode' the values like this:

| getmanagerlogs 10.0.0.90 8000 10.0.0.50 55000 foo bar
| table timestamp, tag, level, description
| search level=$value$

Which are the exactly values that | inputlookup kvstore_lookup | returns.

Thank you for your reply

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...