Deployment Architecture

how to get the month dropdown?

avneet26
Engager

i want to create a dropdown in my dashboarrd where in i can select the month from the current year and it should give em the results based on the events generated in that parrticular month only. How can i do that? and how to pas the token value into my tables in the dashboard?

Labels (1)
0 Karma

somesoni2
Revered Legend

Take a look at this runanywhere dashboard code. The dropdown month will have all the month for current year (calculated based on today). The "<change>" will generate time range tokens which can be used in panel like shown.

 

 

<form>
  <label>TEST</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="month" searchWhenChanged="true">
      <label>month</label>
      <fieldForLabel>month</fieldForLabel>
      <fieldForValue>firstDayOfMonth</fieldForValue>
      <search>
        <query>|  makeresults 
|  eval month=mvrange(1,tonumber(strftime(now(),"%m"))) 
|  mvexpand month  
| eval firstDayOfMonth=strptime("01/".month."/".strftime(now(),"%Y"),"%d/%m/%Y") 
|  eval month=strftime(firstDayOfMonth,"%B")</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <change>
        <!-- use predefined input tokens to set -->
        <!-- tokens for the selected label and value -->
        <set token="earliest_tok">$value$</set>
        <eval token="latest_tok">relative_time($value$,"+1mon@mon")</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>|  makeresults | addinfo | eval message="Selected results for duration ".strftime(info_min_time,"%F %T")." to ".strftime(info_max_time,"%F %T")</query>
          <earliest>$earliest_tok$</earliest>
          <latest>$latest_tok$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>

  

0 Karma

to4kawa
Ultra Champion
<form>
  <label>dropdown token</label>
  <fieldset>
    <input type="dropdown" token="month_token">
      <label>tokens</label>
      <fieldForLabel>label</fieldForLabel>
      <fieldForValue>month</fieldForValue>
      <search>
        <query>| makeresults
| eval month=strftime(_time,"%B")
| eval label=month</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>
          <h2>drop down: $month_token$</h2>
        </p>
      </html>
    </panel>
  </row>
</form>
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...