Reporting

How to Schedule a search for every 30 seconds.

nkchaitanya
Explorer

I need to schedule a saved search for every 30 seconds, but I find the Basic one minute as the minimum schedule, which is also same in crons, please suggest is any other way to schedule for seconds.

Tags (1)

woodcock
Esteemed Legend

You cannot directly but you can run a CLI-based search on the search head so you can setup a cron job with 2 searches to run every second like this:

 * * * * * /my30SecondScript

And then inside my30SecondScript do something like this:

exec '/opt/splunk/bin/splunk search "my search string"'
sleep 30
exec '/opt/splunk/bin/splunk search "my search string"'

znaesh
Path Finder

To have perfect run intervals, a user can append ampersand (&) before every such sleep command.

0 Karma

hylam
Contributor

Is it possible to make a "sleep 30" custom splunk command? Is it possible to make 2 copies of the same saved search, and then put a sleep 30 in one of them?

0 Karma

woodcock
Esteemed Legend

Splunk has a facility to create your own splunk commands but I have never done so so I cannot speak to that. You could to the latter which is the same as my solution but removing the first line of the script code that I wrote.

0 Karma

hylam
Contributor

Where do you put the my30SecondScript?

0 Karma

woodcock
Esteemed Legend
0 Karma

hylam
Contributor

Can I use the splunk job scheduler as a "highly available cron" to run arbitrary scripts? Splunk's job scheduler picks 1 of the search heads in an SHC to run a scheduled search. Splunk's job scheduler also prevents successive long running jobs to overlap.

0 Karma

woodcock
Esteemed Legend

Exactly the plan.

miteshvohra
Contributor

AFAIK, cron does not go down to sub-minute resolutions/granularity.

0 Karma

nkchaitanya
Explorer

Thanks @miteshvohra,
Is there any way to schedule in seconds.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In September, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...