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
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...