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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...