How to create a search manager using SplunkJS Stack

You can create different types of search managers depending on the type of search you want:

  • To set up a search job, create a SearchManager.
  • To use a saved report, create a SavedSearchManager.
  • To set up a post-process search based on another search, create a PostProcessManager.

Here's an example of how to create a manager for a search job in JavaScript.

    require([
        "splunkjs/mvc/searchmanager",
        "splunkjs/mvc/simplexml/ready!"
    ], function(SearchManager) {

    new SearchManager({
        id: "mysearch1",
        earliest_time: "-24h@h",
        latest_time: "now",
        search: "index=_internal | head 100 | stats count by source"
    });
});

For more about working with search properties, progress events, and the search results model, see Search managers.

For a list of the different properties, methods, and events you can use with search managers, see the Splunk Web Framework Component Reference.