Dashboards & Visualizations

How to run search every 5 mins?

josefa123
Explorer

At the moment I am using a real time search to get the latest data. Here it is:

var SearchManager = require("splunkjs/mvc/searchmanager");
        var searchString = '* | JOIN host [ search source="dbmon-dump://SD_DB/RAP" | eval host=device_id]  | stats first(device_id) as DeviceID,first(device_type) as DeviceType, first(rap_id) as RAPID,' +
            'first(store_name) as StoreName,first(address) as Address,first(rap_type) as RAPType,first(region) as Region, first(city) as City,first(cluster) as Cluster,first(trade_area) as TradeArea,' +
            'first(longitude) as Longitude,first(latitude) as Latitude, first(cal) as CAL, first(start_operation_date) as StartOperationDate,first(memUsedPct) as MemoryUsed,first(rKB_PS) as Read, ' +
            'first(wKB_PS) as Write, first(pctSystem) as CPU_Usage, by host| sort -_time';

        var search = new SearchManager({
            id: "cacheSearch",
            earliest_time: "rt-3m",
            latest_time: "rt",
            autostart: true,
            search: searchString,
            preview: true,
            cache: false
        });

However, I need to get the data from the search instance but getting it while searching real-time is impossible because it returns undefined data. I need to have a search that runs every 5 mins but not real time. Any help would be so much appreciated. Thanks.

0 Karma
1 Solution

diogofgm
SplunkTrust
SplunkTrust

Why don't you schedule a search for the last 5 min to run every 5min? You can then use the |loadjob command to load the results and do what ever you need to the results

http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/Loadjob

------------
Hope I was able to help you. If so, some karma would be appreciated.

View solution in original post

0 Karma

diogofgm
SplunkTrust
SplunkTrust

Why don't you schedule a search for the last 5 min to run every 5min? You can then use the |loadjob command to load the results and do what ever you need to the results

http://docs.splunk.com/Documentation/Splunk/6.2.4/SearchReference/Loadjob

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma

josefa123
Explorer

Isn't it just loads the previous results that are on the previous job? It doesn't reload the search but it just gets the results on the previous jobs

0 Karma

diogofgm
SplunkTrust
SplunkTrust

To schedule a search you need to create a saved search by going to settings - searches - new. There you can find the option to schedule the search with basic time options or using cron.
When you use the loadjob you use the name you gave to your saved search. This way will load the search results of the last time splunk runned your search.

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma

josefa123
Explorer

can you do it on Javascript search manager?

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...