Dashboards & Visualizations

Help with time token

tomapatan
Contributor

Hi Everyone,

I`ve got a dropdown input that generates 30 date entries and stores the choice in the "date.tok2" token.
I`d like to be able to pass the token to a table to run a search over the period chosen from the drop down, but this is not working as expected (not generating any results - I know the query works because if I run it independently it produces results, so the problem must be with the token).

I`ve got an identical drop down menu that works fine and it successfully passes the token onto the table at the beginning of the dashboard (that token is called "date.tok" and is used to set "earliest_tok" and "latest_tok").

Any help would be greatly appreciated.

      <input type="dropdown" token="date.tok2" searchWhenChanged="true">
        <label>Date</label>
        <fieldForLabel>Date</fieldForLabel>
        <fieldForValue>earliest</fieldForValue>
        <search>
          <query>| makeresults 
| timechart span=d count 
| sort - _time 
| where _time &lt;= relative_time(now(),"@d") 
| fields - count 
| eval Date = strftime(_time,"%d-%b-%y"), earliest=relative_time(_time,"@d"), latest=relative_time(_time,"@d") 
| dedup Date</query>
          <earliest>-30d@d</earliest>
          <latest>now</latest>
        </search>
        <selectFirstChoice>true</selectFirstChoice>
        <change>
          <set token="earliest_tok2">$row.earliest$</set>
          <set token="latest_tok2">$row.latest$</set>
        </change>
      </input>
      <table>
        <search>
          <query>| ...| ...</query>
          <earliest>$earliest_tok2$</earliest>
          <latest>$latest_tok2$</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">none</option>
        <option name="rowNumbers">false</option>
        <option name="wrap">true</option>
      </table>

 

 

Labels (1)
0 Karma
1 Solution

tomapatan
Contributor

Found the problem...the latest time was same as the earliest time.
Correct syntax: 

| eval Date = strftime(_time,"%d-%b-%y"), earliest=relative_time(_time,"@d"), latest=relative_time(_time,"+d@d") 

 

View solution in original post

0 Karma

tomapatan
Contributor

Found the problem...the latest time was same as the earliest time.
Correct syntax: 

| eval Date = strftime(_time,"%d-%b-%y"), earliest=relative_time(_time,"@d"), latest=relative_time(_time,"+d@d") 

 

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!

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...