Splunk Search

How to issue a search from a dashboard panel with inputs to populate an index?

bruceclarke
Contributor

I have an HTML panel and custom javascript on my dashboard. The panel has a few inputs that I want the user to populate, then click a button to take these inputs and run a search. Right now I have something like:

var bottleNeckVal = $("input:radio[name=bottleneck]:checked").val(),
    notes = $("additional-info-text").val(),
    bottleNeckSpecifics = "blah";

tokens.set("bottleNeck",bottleNeckVal);
tokens.set("bottleNeckSpecifics",bottleNeckSpecifics);
tokens.set("notes",notes);

var populateIndex = new SearchManager({
    id: "populate-index-search",
    search: 'index=boomerangrequestlog RequestId=$formRequestId$\
 | eval bottleNeck=$bottleNeck$, bottleNeckSpecifics=$bottleNeckSpecifics$, notes=$notes$\
 | table _time EnvironmentNonGateway RequestId absoluteUri assetLoadDurSecs browserDurSecs clientIp dbName externalHost machineNames networkDurSecs nonAssetLoadDurSecs numResourcesLoaded path referrer roundTripDurSecs serverDurSecs url userId userName bottleNeck bottleNeckSpecifics notes\
 | collect index="scratch" testmode=f addtime=t timeformat="%m/%d/%Y %H:%M:%S.%3N"',
    earliest_time: "$formTimeRange.earliest$",
    latest_time: "$formTimeRange.latest$",
    preview: true,
    cache: true
}, { tokens: true });

populateIndex.startSearch();
populateIndex.finalize();

So, I want this information to populate my scratch index, but it never appears like the search is running. It's definitely hitting the code, but the data never shows up in the scratch index.

0 Karma

bruceclarke
Contributor

So, for some reason the tokens that I set in javascript weren't getting to the search correctly. I got around this by just setting the complete search string in javascript and no longer using tokens in the search object.

It's unclear and troubling as to why this search wasn't populating the tokens correctly. Does anyone have any thoughts?

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...