Reporting

How to display the timerange of cron schedule in dashboard

madanashok
Path Finder

Hi Splunkers,

There is a need for me to display at what duration the saved search is running in dashboard panel.

specifically in html module.

For instance the cron schedule is 00,20,40 * * * *

I want to display like the search is running at 12.20 - 12.40 in html module.Likewise 1.10-1.30 .

Thanks,
Madan

Tags (1)
1 Solution

jonuwz
Influencer

This is only an approximation.

This gets you

1) the time range covered by the last run search (range)

2) the difference between searchLatestTime for the current and the previous job (interval)

Providing the cron schedule is regular (i.e runs at the same interval always) the output for interval will be reasonably accurate.

| rest /services/search/jobs 
| search isSavedSearch=1
| stats max(searchEarliestTime) as sET max(searchLatestTime) as sLT list(searchLatestTime) as times by label
| eval range=strftime(sET,"%H:%M")." - ".strftime(sLT,"%H:%M")
| eval interval=strftime(mvindex(times,1),"%H:%M")." - ".strftime(mvindex(times,0),"%H:%M")
| table label range interval

The cron schedule is exposed like this, but its ugly :

| rest /servicesNS/-/-/saved/searches | search is_scheduled=1 | table title cron_schedule

View solution in original post

jonuwz
Influencer

This is only an approximation.

This gets you

1) the time range covered by the last run search (range)

2) the difference between searchLatestTime for the current and the previous job (interval)

Providing the cron schedule is regular (i.e runs at the same interval always) the output for interval will be reasonably accurate.

| rest /services/search/jobs 
| search isSavedSearch=1
| stats max(searchEarliestTime) as sET max(searchLatestTime) as sLT list(searchLatestTime) as times by label
| eval range=strftime(sET,"%H:%M")." - ".strftime(sLT,"%H:%M")
| eval interval=strftime(mvindex(times,1),"%H:%M")." - ".strftime(mvindex(times,0),"%H:%M")
| table label range interval

The cron schedule is exposed like this, but its ugly :

| rest /servicesNS/-/-/saved/searches | search is_scheduled=1 | table title cron_schedule

jonuwz
Influencer

Good. If this answers your question, please consider accepting the answer.

0 Karma

madanashok
Path Finder

Excellent jonuwz...I got what i wanted.

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...