Dashboards & Visualizations

Time comparison - Relative and Explict

manas
Explorer

I have a field which gives when a particular event started. Depending on time period selected in dashboard , i want to fetch all records past that time period selected in time picker input of the dashboard.

 

Problem is if time input is relative like "today" /"Yesterday" choice 1 below works and i get results. When time selected as input is explicit like "10/02/2025"  ,choice 2 works and i get results. 

Relative time logic :

|where timestamp2 >= relative_time(now(), "$field1.earliest$")

Explicit time logic :

|where timestamp2 >= tonumber("$field1.earliest$")

  How to enhance this ,so that irrespective of input ,will get results.

Something like below does not work :

 

| eval earliest_time=if(isnum("$field1.earliest$"), tonumber("$field1.earliest$"), relative_time(now(), "$field1.earliest$"))
| where  timestamp2 >= earliest_time

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Possibly the simplest answer is to let Splunk do it for you. You can use addinfo to get the search time settings and use them in your search

| addinfo
| where timestamp2 >= info_min_time

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Possibly the simplest answer is to let Splunk do it for you. You can use addinfo to get the search time settings and use them in your search

| addinfo
| where timestamp2 >= info_min_time

manas
Explorer

This works . Thanks . I have multiple time pickers in dashboard as it's a comparison dashboard as given each widget has it's own time picker ,it works regardless. 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...