Splunk Search

Passing variable to populatingSearch

anujojha
New Member

This is what I am trying to do:
I have a time range drop down which will provide value to a dynamic populated drop down. I have tried the following but it fail saying "Invalid value "$earliest$" for time term 'earliest'"

{code}


2 days
3 days

<input type="dropdown" token="id">
  <label>ID</label>
  <populatingSearch fieldForValue="ID" fieldForLabel="ID">
  <![CDATA[search index=login sourcetype=login_logs earliest="$earliest$" | dedup 1 ID]]>
  </populatingSearch>
</input>

{code}

If I provide a string value as earliest="-2d@d" it works. But I want the drop down to populate the value in search string. Is it possible to earliest as:
as argument?

Tags (1)
0 Karma

anujojha
New Member

If I use tag then it does not uses the days provided from drop down it take default days.

0 Karma

lguinn2
Legend

I think you are close, what if you do this

<input type="dropdown" searchwhenchanged="true" token="earliest">
      <choice value="-2d@d">2 days</choice>
      <choice value="-3d@d">3 days</choice>
    </input>

<input type="dropdown" token="id">
  <label>ID</label>
  <populatingSearch fieldForValue="ID" fieldForLabel="ID">
      <![CDATA[search index=login sourcetype=login_logs| dedup 1 ID]]>
      <earliestTime>$earliest$</earliestTime>
  </populatingSearch>
</input>

Notice that I moved the $earliest$ token from within the populating search and into a separate tag.

0 Karma

anujojha
New Member

If I use tag then it does not uses the days provided from drop down it take default days.

0 Karma
Get Updates on the Splunk Community!

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

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...