Splunk Search

How do I output the Search Managers results value?

kedjjang
Path Finder

var deps = [
"jquery",
"splunkjs/ready!",
"splunkjs/mvc/searchmanager"
];
require(deps, function(mvc) {
// Load individual components
var SearchManager = require("splunkjs/mvc/searchmanager");

    // Create the search manager
    var mysearch = new SearchManager({
        id: "search1",
        app: "search",
         earliest_time: "-7d@d",
                     latest_time: "now",
        cache: false,
        search: "index="test_summary" | eval result = 99999 | fields result" 
    });

    mysearch.on('search:failed', function(properties) {
        // Print the entire properties object
        console.log("FAILED:", properties);
        $("#aa").text("Failed!");
    });

    mysearch.on('search:progress', function(properties) {
        // Print just the event count from the search job
        console.log("IN PROGRESS.\nEvents so far:", properties.content.eventCount);
       $("#aa").text("In progress with " + properties.content.eventCount + " events...");
    });

    mysearch.on('search:done', function(properties) {
        // Print the search job properties
        console.log("DONE!\nSearch job properties:", properties.content);            
    $("#aa").text("Done!"+properties.content);
    });
});

I want to output the result to the spl ("# aa").
How do I output the results of the spl?

Tags (2)
0 Karma
1 Solution

acharlieh
Influencer

Typically you would create some kind of View Object (be it a table or chart of some kind, that would reference the manager, and would render the results in an element.)

The Web Framework Docs have a few examples of this. It looks like you followed the Search Progress Events Example but it sounds like you would be interested in the Basic Template Example which renders events in a ChartView and an EventsViewerView. Or this other one that uses a TableView.

View solution in original post

piebob
Splunk Employee
Splunk Employee

please don't yell. i am going to remove all the extra question marks.
please provide more details about what you're trying to do.

acharlieh
Influencer

Typically you would create some kind of View Object (be it a table or chart of some kind, that would reference the manager, and would render the results in an element.)

The Web Framework Docs have a few examples of this. It looks like you followed the Search Progress Events Example but it sounds like you would be interested in the Basic Template Example which renders events in a ChartView and an EventsViewerView. Or this other one that uses a TableView.

Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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