<?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: Query substring of value stored in token in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397053#M173701</link>
    <description>&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval matchstring=if(match(ip_field,replace($token|s$,"(?&amp;lt;=\.)[^.]*$","")),ip_field,null())|where isnotnull(matchfield)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Jan 2019 19:04:52 GMT</pubDate>
    <dc:creator>cmerriman</dc:creator>
    <dc:date>2019-01-11T19:04:52Z</dc:date>
    <item>
      <title>Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397051#M173699</link>
      <description>&lt;P&gt;I have a $token$ with value 192.168.25.2. How do I perform a query for all addresses that have 192.168.25.* excluding 192.168.25.2?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 16:00:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397051#M173699</guid>
      <dc:creator>burchl</dc:creator>
      <dc:date>2019-01-11T16:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397052#M173700</link>
      <description>&lt;P&gt;Hi @burchl &lt;/P&gt;

&lt;P&gt;Please try below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" 
| eval ip ="192.168.56.5" 
| where clientip !=ip 
| rex field=ip mode=sed "s/(\d{1,3}$)/%/g" 
| stats values(clientip) as test by ip
| mvexpand test| where like (test,ip) 
| table test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here it eliminates 192.168.56.5 and searches 192.168.56.*&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 18:54:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397052#M173700</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-11T18:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397053#M173701</link>
      <description>&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval matchstring=if(match(ip_field,replace($token|s$,"(?&amp;lt;=\.)[^.]*$","")),ip_field,null())|where isnotnull(matchfield)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 19:04:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397053#M173701</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2019-01-11T19:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397054#M173702</link>
      <description>&lt;P&gt;@burchl how is &lt;CODE&gt;$token$&lt;/CODE&gt; set? Is it coming from any form input. Can you share the code?&lt;BR /&gt;
Also what is the SPL where you want to apply required filter?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 19:34:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397054#M173702</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-11T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397055#M173703</link>
      <description>&lt;P&gt;You can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=YouShouldAlwaysSpecifyAnIndex AND sourcetype=AndSourcetypeToo [|makeresults | eval host="$token$" | rex field=host mode=sed "s/\.[^\.]+$/*/"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jan 2019 19:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397055#M173703</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-11T19:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397056#M173704</link>
      <description>&lt;P&gt;$token$ is set from form input. I can't share the code unfortunately. I will try your instructions.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 19:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397056#M173704</guid>
      <dc:creator>burchl</dc:creator>
      <dc:date>2019-01-11T19:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397057#M173705</link>
      <description>&lt;P&gt;Is the input dropdown or textbox or something else?&lt;BR /&gt;
If you can mock/anonymize information and provide more details that would be great. However, we can also try with some questions to see what is best applicable.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 20:27:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397057#M173705</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-11T20:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Query substring of value stored in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397058#M173706</link>
      <description>&lt;P&gt;@burchl&lt;/P&gt;

&lt;P&gt;Can you please try this XML?&lt;/P&gt;

&lt;P&gt;This Dashboard will show you sample data panel and token value in other HTML panel. You can chanege  &lt;CODE&gt;eval&lt;/CODE&gt; token logic as per your requirement,  Try and let me know. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;IP Token&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="text" token="token"&amp;gt;
      &amp;lt;label&amp;gt;IP&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
                &amp;lt;eval token="filter"&amp;gt;replace($value$,"(?&amp;lt;=\.)[^.]*$","")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;My Sample Data&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval IP="192.168.25.2,192.168.25.1,192.168.25.3,192.168.25.4" | eval IP=split(IP,",") | mvexpand IP&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        My Token Value:  $token$ &amp;amp;lt;br/&amp;amp;gt;
        My Passed Value: $filter$ &amp;amp;lt;br/&amp;amp;gt;
      &amp;lt;/html&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;My Result&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults | eval IP="192.168.25.2,192.168.25.1,192.168.25.3,192.168.25.4" | eval IP=split(IP,",") | mvexpand IP | eval comment="Up to this your search" | search IP=$filter$* AND IP!=$token$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note:&lt;/P&gt;

&lt;P&gt;1) eval statements changed in this answer. make sure eval token filter would be the &lt;CODE&gt;&amp;lt;eval token="filter"&amp;gt;replace($value$,"(?&amp;amp;lt;=\.)[^.]*$","")&amp;lt;/eval&amp;gt;&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;2) html panel would be like &lt;CODE&gt;&lt;BR /&gt;
        My Token Value:  $token$ &amp;amp;lt;br/&amp;amp;gt;&lt;BR /&gt;
        My Passed Value: $filter$ &amp;amp;lt;br/&amp;amp;gt;&lt;BR /&gt;
      &amp;lt;/html&amp;gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 03:53:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-substring-of-value-stored-in-token/m-p/397058#M173706</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-14T03:53:10Z</dc:date>
    </item>
  </channel>
</rss>

