<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: search on variable in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493629#M137663</link>
    <description>&lt;P&gt;Hi scottfoley,&lt;BR /&gt;
the easiest solution would be to define a drop down field to select the stem and add the label/value pairs so that for example the first label reads &lt;CODE&gt;Item1&lt;/CODE&gt; and the first value reads &lt;CODE&gt;/item1/.*&lt;/CODE&gt;. Call the token &lt;EM&gt;selection&lt;/EM&gt;. Now, if you select "Item1" from the list, the value of selection will be /item1/.* Use it in your search like such: &lt;CODE&gt;sourcetype=iis | regex cs_uri_stem="$selection$" | eval search_stem="$selection$" | table cs_uri_stem search_stem&lt;/CODE&gt; &lt;BR /&gt;
With dynamic stems, you could also dynamically fill the dropdown values from a search.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2019 17:10:48 GMT</pubDate>
    <dc:creator>ololdach</dc:creator>
    <dc:date>2019-10-07T17:10:48Z</dc:date>
    <item>
      <title>search on variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493628#M137662</link>
      <description>&lt;P&gt;I have a dashboard where I select the type of item I want to look for in an IIS log.  What I look for is a regular expression, but I can show the problem using a simple wildcard. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval search_stem = "/item/*"
| search cs_uri_stem = search_stem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns nothing.  If I replace the search with the actual string it works fine.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search cs_uri_stem = "/item/*" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The cs_uri_stem searched for will be a regex expression.  Something like this, but more complicated regex and items.    &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype=iis 
| eval search_stem = case (
   $selection$="item1","/item1/.*",
   $selection$="item2","/item2/.*",
   $selection$="item3","/item3/.*"
)
| regex cs_uri_stem=search_stem
| table  cs_uri_stem search_stem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I use the table to show that the search_stem is correct.  I can't seem to get a trivial example working where I base a search on a variable that contains a wildcard.  A similar question to this was answered using the where clause, but that does not work with wildcards or regex.  &lt;/P&gt;

&lt;P&gt;Any suggestions?    &lt;/P&gt;

&lt;P&gt;I am using Splunk Cloud 7.0.11.1&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493628#M137662</guid>
      <dc:creator>scottfoley</dc:creator>
      <dc:date>2020-09-30T02:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: search on variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493629#M137663</link>
      <description>&lt;P&gt;Hi scottfoley,&lt;BR /&gt;
the easiest solution would be to define a drop down field to select the stem and add the label/value pairs so that for example the first label reads &lt;CODE&gt;Item1&lt;/CODE&gt; and the first value reads &lt;CODE&gt;/item1/.*&lt;/CODE&gt;. Call the token &lt;EM&gt;selection&lt;/EM&gt;. Now, if you select "Item1" from the list, the value of selection will be /item1/.* Use it in your search like such: &lt;CODE&gt;sourcetype=iis | regex cs_uri_stem="$selection$" | eval search_stem="$selection$" | table cs_uri_stem search_stem&lt;/CODE&gt; &lt;BR /&gt;
With dynamic stems, you could also dynamically fill the dropdown values from a search.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 17:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493629#M137663</guid>
      <dc:creator>ololdach</dc:creator>
      <dc:date>2019-10-07T17:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: search on variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493630#M137664</link>
      <description>&lt;P&gt;That works.  That was my end goal, but I wonder why my example did not work.  Still my example was contrived and not something that someone would normally do.  I was just testing things outside of a dashboard.  &lt;/P&gt;

&lt;P&gt;Thanks  &lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 15:31:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493630#M137664</guid>
      <dc:creator>scottfoley</dc:creator>
      <dc:date>2019-10-09T15:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: search on variable</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493631#M137665</link>
      <description>&lt;P&gt;Hi scottfoley, it appears that splunk treats the content of a variable different from literal values in a &lt;EM&gt;search&lt;/EM&gt; command. Variables don't pass through the wildcard processing. Dashboard tokens, however, are being treated as literal values. If you want to implement it somewhat like in your example, try &lt;CODE&gt;...|where cs_uri_stem like search_stem."%"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 05:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-on-variable/m-p/493631#M137665</guid>
      <dc:creator>ololdach</dc:creator>
      <dc:date>2019-10-10T05:39:46Z</dc:date>
    </item>
  </channel>
</rss>

