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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...