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

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...