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.
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
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
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
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.
can you do it on Javascript search manager?