Dashboards & Visualizations

Update query when multiselect changed/updated

vschrodda
Explorer

How can I get the my queries to update when I change the contents of the multiselect input (Select Users)?  Right now, the data will only update the data with the updated $user_tok$ when changing the selection in the Log type dropdown:

vschrodda_0-1623102274013.png

 

 

<form>
  <label>Data Lookup</label>
  <description>Display stats for a given user</description>
  <search id="baseSearch">
    <query>index=source_db sourcetype=source_type Username="*$site_tok$*" | table _time,_raw,Username,roundtrip_ms,client_to_agent_packetloss</query>
    <earliest>$time_tok.earliest$</earliest>
    <latest>$time_tok.latest$</latest>
  </search>
  <fieldset submitButton="false" autoRun="true">
    <input type="text" token="site_tok" searchWhenChanged="true">
      <label>Enter Site</label>
      <default></default>
    </input>
    <input type="time" token="time_tok" searchWhenChanged="true">
      <label>Date</label>
      <default>
        <earliest>-7d@h</earliest>
        <latest>now</latest>
      </default>
    </input>
    <input type="multiselect" token="user_tok" searchWhenChanged="true">
      <label>Select Users</label>
      <search base="baseSearch" id="user_search">
        <query>| eval Username=mvindex(split(Username,"\\"),-1) | dedup Username | sort Username</query>
      </search>
      <fieldForLabel>Username</fieldForLabel>
      <fieldForValue>Username</fieldForValue>
      <valuePrefix>Username="*</valuePrefix>
      <delimiter> OR </delimiter>
      <valueSuffix>"</valueSuffix>
    </input>
    <input type="dropdown" token="result_type" searchWhenChanged="true">
      <label>Log type</label>
      <choice value="P_LOSS">Packet Loss</choice>
      <choice value="MGMT_PROTO_DATA">Latency</choice>
      <default></default>
      <change>
        <condition label="Latency">
          <unset token="result1"></unset>
          <set token="result1">| search _raw="*$result_type$*" $user_tok$ | where roundtrip_ms!=" " | sort _time | table _time,_raw,roundtrip_ms</set>
          <unset token="result2"></unset>
          <set token="result2">| search _raw="*$result_type$*" $user_tok$ | where roundtrip_ms!=" " | sort _time | eval roundtrip_ms=roundtrip_ms | timechart span=1s values(roundtrip_ms) BY Username</set>
        </condition>
        <condition label="Packet Loss">
          <unset token="result1"></unset>
          <set token="result1">| search _raw="*$result_type$*" $user_tok$ | table _time,_raw,client_to_agent_packetloss</set>
          <unset token="result2"></unset>
          <set token="result2">| search _raw="*$result_type$*" $user_tok$ | eval packet_loss=client_to_agent_packetloss | timechart span=1s values(packet_loss) BY Username</set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Performance statistics</title>
      <chart>
        <search base="baseSearch">
          <query>$result2$</query>
        </search>
        <option name="charting.chart">line</option>
        <option name="charting.chart.nullValueMode">connect</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
      <table>
        <title>Query Data</title>
        <search base="baseSearch">
          <query>$result1$</query>
        </search>
      </table>
    </panel>
  </row>
</form>

 

 

Labels (3)
0 Karma
1 Solution

vschrodda
Explorer

Fixed my issue by updating the queries

    <panel>
      <title>Performance statistics</title>
      <chart>
        <search base="baseSearch">
          <query>search $user_tok$ | search $result2$</query>
        </search>
        <option name="charting.chart">line</option>
        <option name="charting.chart.nullValueMode">connect</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
      <table>
        <title>Query Data</title>
        <search base="baseSearch>
          <query>| search $user_tok$ | search $result1$</query>
        </search>
      </table>
    </panel>

View solution in original post

0 Karma

vschrodda
Explorer

Fixed my issue by updating the queries

    <panel>
      <title>Performance statistics</title>
      <chart>
        <search base="baseSearch">
          <query>search $user_tok$ | search $result2$</query>
        </search>
        <option name="charting.chart">line</option>
        <option name="charting.chart.nullValueMode">connect</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
      <table>
        <title>Query Data</title>
        <search base="baseSearch>
          <query>| search $user_tok$ | search $result1$</query>
        </search>
      </table>
    </panel>
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!

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 ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...