Reporting

Is it possible to determine the last time a saved search was executed?

kbecker
Communicator

I am looking to audit the non-scheduled saved searches that users have created, is there a way to obtain the last run time of each saved search?

Tags (1)
0 Karma

araitz
Splunk Employee
Splunk Employee
index="_internal" (sourcetype="splunk_web_service" view "loading saved search") 
OR (sourcetype=splunkd_access "GET /servicesNS/" "/search/saved/searches") 
| rex "loading saved search \"(?<saved_search>[^\"]+)" 
| eval uri_decode = urldecode(uri) 
| rex field=uri_decode "saved\/searches\/(?<saved_search>[^\$]+)$" 
| search saved_search=* NOT saved_search="_new" 
| transaction saved_search maxspan=2s
| search sourcetype="splunk_web_service" AND sourcetype="splunkd_access" 
| stats first(user) as user last(_time) as last_run_time by saved_search 
| fieldformat last_run_time=strftime(last_run_time, "%m/%d/%Y %H:%M:%S")

netwrkr
Communicator

I know this query can be written better but it works 😉

audit_searchlocal | audit_rexsearch | search search_id!=scheduler_* | search search=search* search!=*_internal* search!=*_audit* | search NOT audit_search* | search NOT audittrail

HTH

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...