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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...