Reporting

custom timeframe on cli with saved searches

zscgeek
Path Finder

How do you change the time period of a saved search when running from the CLI?

Right now I have a saved search that runs over a 30min window by default. I normally will run it like this:

/opt/splunk/bin/splunk search  "|savedsearch \"Top HTTP Response Codes\""

Assuming I want to run that same saved search over a 1h window what can I do? I tried this but it did not seem to work:

/opt/splunk/bin/splunk search  "|savedsearch \"Top HTTP Response Codes\"" -earliest_time "−50m" 

I don't get any errors but it ran it over the same timeframe as before.

Tags (3)
1 Solution

Ellen
Splunk Employee
Splunk Employee

This was fixed since 4.2 under SPL-35277.

Here is a sample CLI that will override the time period existing in a saved search to your custom one (eg. May 6, 2013 7:00am to May 18, 2013 11:00pm) on the Splunk search command line.

$SPLUNK_HOME/bin/splunk search "| savedsearch ChgTime" -auth admin:changeme -earliest_time "2013-05-06T07:00:00.000" -latest_time "2013-05-18T23:00:00.000" -time_format "%FT%T.%Q"

View solution in original post

Ellen
Splunk Employee
Splunk Employee

This was fixed since 4.2 under SPL-35277.

Here is a sample CLI that will override the time period existing in a saved search to your custom one (eg. May 6, 2013 7:00am to May 18, 2013 11:00pm) on the Splunk search command line.

$SPLUNK_HOME/bin/splunk search "| savedsearch ChgTime" -auth admin:changeme -earliest_time "2013-05-06T07:00:00.000" -latest_time "2013-05-18T23:00:00.000" -time_format "%FT%T.%Q"

solarboyz1
Builder

Is this still the case? I can't find any reference to SPL-33374, or any information regarding adjusting the time frame of a saved search.

0 Karma

SeanWilliams
New Member

Is this still the case ?? can you still not use a defined time frame on a saved search ?

0 Karma

Ledion_Bitincka
Splunk Employee
Splunk Employee

currently there is no way to override the time range over which the savedsearch is executed when ran from the CLI. Unfortunately there currently is no workaround for this issue.

I have filed a bug, SPL-33374, which should be fixed in one of the next maintenance releases.

Get Updates on the Splunk Community!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...