Dashboards & Visualizations

How to change the group by clause in timechart command depending on selected value in drop-down?

praspai
Path Finder

I want to change the group by clause in search command depending upon selected value in drop-down box in dashboard

e.g. Selected value is "All" then group by clause should look like timechart sum(x) group by host
else
Selected value is "Environment" then group by clause should look like timechart sum(x) group by environment

Thanks,
Prashant

0 Karma
1 Solution

rjthibod
Champion

You can easily do this with the <change> option on your input dropdown.

    <input id="split_field" searchWhenChanged="true" token="split_field" type="dropdown">
      <label>Split-by Field</label>
      <choice value="all">All</choice>
      ...
      <choice value="env">Environment</choice>
      <default>all</default>
      <change>
        <condition label="All">
          <set token="split_field_opt">host</set>
        </condition>
       ...
        <condition label="Environment">
          <set token="split_field_opt">environment</set>
        </condition>        
      </change>
    </input>
    ...
    <panel>
      <chart>
        <search><query>YOUR SEARCH | timechart sum(x) group by  $split_field_opt$</query></search>
      </chart>
    </panel>

View solution in original post

rjthibod
Champion

You can easily do this with the <change> option on your input dropdown.

    <input id="split_field" searchWhenChanged="true" token="split_field" type="dropdown">
      <label>Split-by Field</label>
      <choice value="all">All</choice>
      ...
      <choice value="env">Environment</choice>
      <default>all</default>
      <change>
        <condition label="All">
          <set token="split_field_opt">host</set>
        </condition>
       ...
        <condition label="Environment">
          <set token="split_field_opt">environment</set>
        </condition>        
      </change>
    </input>
    ...
    <panel>
      <chart>
        <search><query>YOUR SEARCH | timechart sum(x) group by  $split_field_opt$</query></search>
      </chart>
    </panel>
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...