Splunk Enterprise

get earliest time from timepicker in custom commands

raindad85
New Member

Hi splunkers,

I Create a Splunk custom commands which take information in another website, with the splunk sdk 'splunklib.searchcommands'. I have used the generatingCommand class, and my python script is like :

| getinfo url=<url> earliest=<timestamp> latest=<timestamp

the custom command is working, but i would tike to take the earliest time and last time from the timepicker ,when splunk user want to use it. my custom command will be then:

 |getinfo url =<url> 

and i will use the timepicker information in my 'earliest' and 'latest' option.

So, i can we get these earliest and latest time , from the UI timepicker to my python script, using the generatingCommand class ?

I hava alreay used this code below but it doen't work:

searchresults = GeneratingCommand.metadata

spl_earliest_time = int(searchresults.searchinfo.earliest_time)
spl_latest_time = int(searchresults.searchinfo.latest_time)

Also, if the time is like "-7d@d", how to change it to UTC timestamp

can someone help?

thanks in advance,

 

Labels (2)
0 Karma

lumpymilk
Explorer

From what I can tell, these look like the right attributes. They show up with a float so you may have to convert them depending on what you're using it for.

earliest = self.search_results_info.api_et
latest = self.search_results_info.api_lt

I'd like to know how to create an Option() that uses the same validator as what search uses.  LMK if you find that.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...