Splunk Dev

Running a base search from SplunkJS

ollie920049
Path Finder

 Hi,

I'm writing a dashboard with some panels based off an expanding table rows from the Splunk Dashboard 6.x examples app.

alt text

Code as follows:

require([ ... ){
    var EventSearchBasedRowExpansionRenderer = TableView.BaseRowExpansionRenderer.extend({
        initialize: function(args) {
            this._searchManager = new SearchManager({
                id: 'details-search-manager',
                preview: false
            });
            this._chartView = new ChartView({
                managerid: 'details-search-manager',
                'charting.legend.placement': 'none'
            });
        },
        canRender: function(rowData) {
            return true;
        },
        render: function($container, rowData) {
            var sourcetypeCell = _(rowData.cells).find(function (cell) {
               return cell.field === 'sourcetype';
            });
            this._searchManager.set({ search: 'index=_internal sourcetype=' + sourcetypeCell.value + ' | timechart count'});
            $container.append(this._chartView.render().el);
        }
    });
    var tableElement = mvc.Components.getInstance("expand_with_events");
    tableElement.getVisualization(function(tableView) {
        tableView.addRowExpansionRenderer(new EventSearchBasedRowExpansionRenderer());
    });
});

This all works very nice. What I really need though is to be able to access my base search for the dashboard I've written from javascript, and run my searchManager using that (with my customised search appended), if at all possible.

Hope this makes sense? Any suggestions are appreciated, I'll keep digging through the developer doco in the meantime.

Thanks,
Ollie

Tags (2)
0 Karma

sundareshr
Legend

To use your base search, you should use the postprocessmanager and not the searchamanger

http://docs.splunk.com/DocumentationStatic/WebFramework/1.0/compref_postprocessmanager.html

Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...