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>

  

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!

Fall Into Learning with New Splunk Education Courses

Every month, Splunk Education releases new courses to help you branch out, strengthen your data science roots, ...

Super Optimize your Splunk Stats Searches: Unlocking the Power of tstats, TERM, and ...

By Martin Hettervik, Senior Consultant and Team Leader at Accelerate at Iver, Splunk MVPThe stats command is ...

How Splunk Observability Cloud Prevented a Major Payment Crisis in Minutes

Your bank's payment processing system is humming along during a busy afternoon, handling millions in hourly ...