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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...