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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...