Dashboards & Visualizations

User a token with where and like

chadman
Path Finder

I have a search and can use something like | WHERE LIKE(Workstation, "%partofsearchgoeshere%"). I was hopping I could do something like this with a token, but it's not showing any results. I tried this | WHERE LIKE(Workstation, "%$token$%")

0 Karma
1 Solution

tiagofbmm
Influencer

Please re-check you dashboard script for errors. I just tried it and it works the same way. Check the example below as it is generic and you can copy it for your test environment:

<form>
  <label>tokenwhere</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="src">
      <label>field1</label>
      <fieldForLabel>source</fieldForLabel>
      <fieldForValue>source</fieldForValue>
      <search>
        <query>| tstats count where index=_internal by source</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <chart>
        <search>
          <query>index=_internal | where LIKE(source,"%$src$%") | timechart count</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">line</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
    </panel>
  </row>
</form>

View solution in original post

tiagofbmm
Influencer

Please re-check you dashboard script for errors. I just tried it and it works the same way. Check the example below as it is generic and you can copy it for your test environment:

<form>
  <label>tokenwhere</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="src">
      <label>field1</label>
      <fieldForLabel>source</fieldForLabel>
      <fieldForValue>source</fieldForValue>
      <search>
        <query>| tstats count where index=_internal by source</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <chart>
        <search>
          <query>index=_internal | where LIKE(source,"%$src$%") | timechart count</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">line</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
    </panel>
  </row>
</form>

chadman
Path Finder

Opps, I had * for my token and it was putting a * after my search so it looks like | WHERE LIKE(Workstation, "%src*%")

Thanks!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...