<?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: How to pass argument (dynamically) to searchmatch function without use map command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477722#M192741</link>
    <description>&lt;P&gt;Argument for &lt;CODE&gt;searchmatch&lt;/CODE&gt; is a string not a field. You need to put search string "var OR fo*" in &lt;CODE&gt;searchmatch&lt;/CODE&gt; function.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw = "foo var" | eval test1 = if(searchmatch("var OR fo*"), "yes", "no"), test2 = if(searchmatch("var AND foo"), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to pass search string as a parameter then save your search as a saved search (Report) and use &lt;CODE&gt;savedsearch&lt;/CODE&gt; command to call saved search with parameter:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval test = if(searchmatch("$search_string$"), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Save this search as &lt;CODE&gt;saved_search_name&lt;/CODE&gt; and call it using &lt;CODE&gt;savedsearch&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | savedsearch saved_search_name search_string="var OR fo*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 18 Apr 2020 13:36:57 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2020-04-18T13:36:57Z</dc:date>
    <item>
      <title>How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477719#M192738</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wonder test different pattern matching (format spl) dynamically with a field value without use the command "map"&lt;/P&gt;

&lt;P&gt;example:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults | eval _raw = "foo var"  | eval mymatch = "var OR fo*" | eval test = if(searchmatch($mymatch$),"yes","no"&lt;/CODE&gt;)&lt;/P&gt;

&lt;P&gt;I test with macro but it doesn't work.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 03:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477719#M192738</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-18T03:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477720#M192739</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;searchmatch(X)  Use this function to return TRUE if the search string (X) matches the event.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;reference:&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;sample solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="foo bar"
| eval test = if(searchmatch([|makeresults |eval query="\"bar\""|fields - _*]),"yes","no")
|appendpipe[
| eval test = if(searchmatch([|makeresults |eval query="\"foo\""|fields - _*]),"yes","no")
|appendpipe[
| eval test = if(searchmatch([|makeresults |eval query="\"foo OR bar\""|fields - _*]),"yes","no")]]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sorry, I have a mistake.&lt;/P&gt;

&lt;P&gt;Inside &lt;CODE&gt;searchmatch&lt;/CODE&gt;, it can't use boolean expression like &lt;CODE&gt;OR&lt;/CODE&gt;.&lt;BR /&gt;
check my latest comment and try &lt;CODE&gt;lookup(wildcard)&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 05:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477720#M192739</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-18T05:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477721#M192740</link>
      <description>&lt;P&gt;it doesn't work, because it don't take the field value in the function searchmatch , it's a empty string.&lt;/P&gt;

&lt;P&gt;In search.log:&lt;BR /&gt;
 04-18-2020 13:21:02.396 INFO  ForeachProcessor - search for field 'mymatch' =  eval test = if(searchmatch(""),"yes","no")&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 11:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477721#M192740</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-18T11:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477722#M192741</link>
      <description>&lt;P&gt;Argument for &lt;CODE&gt;searchmatch&lt;/CODE&gt; is a string not a field. You need to put search string "var OR fo*" in &lt;CODE&gt;searchmatch&lt;/CODE&gt; function.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw = "foo var" | eval test1 = if(searchmatch("var OR fo*"), "yes", "no"), test2 = if(searchmatch("var AND foo"), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to pass search string as a parameter then save your search as a saved search (Report) and use &lt;CODE&gt;savedsearch&lt;/CODE&gt; command to call saved search with parameter:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval test = if(searchmatch("$search_string$"), "yes", "no")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Save this search as &lt;CODE&gt;saved_search_name&lt;/CODE&gt; and call it using &lt;CODE&gt;savedsearch&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | savedsearch saved_search_name search_string="var OR fo*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Apr 2020 13:36:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477722#M192741</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-04-18T13:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477723#M192742</link>
      <description>&lt;P&gt;thanks!&lt;/P&gt;

&lt;P&gt;But, your solution can't work with multiples patterns&lt;/P&gt;

&lt;P&gt;My patterns are in a lookup, and for every patterns, i've specifics values in others fields.&lt;/P&gt;

&lt;P&gt;The goal is to compare a lot of _raw with multiples patterns in my lookup for monitoring log.&lt;/P&gt;

&lt;P&gt;does it exist a library in python for use function searchmatch ?, i can develop a custom command with it that will take parameter in searchmatch function because is not possible dynamically with splunk core without use map command.&lt;/P&gt;

&lt;P&gt;my wish:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults  | eval _raw="foo bar var"| eval different_pattern ="var OR test,foo AND bar,bar" | makemv different_pattern delim="," | mvexpand different_pattern_spl_format | eval result =if(searchmatch($different_pattern_spl_format_value$),"yes","no")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Apr 2020 16:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477723#M192742</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-18T16:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477724#M192743</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8708i9FCB5D294A3D2CA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;my version 8.0.1&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 21:22:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477724#M192743</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-18T21:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477725#M192744</link>
      <description>&lt;P&gt;@to4kawa &lt;BR /&gt;
Thanks for the help! But it's doesn't work&lt;/P&gt;

&lt;P&gt;Test the spl below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="foo bar"| eval mymatch = "nomatch1 OR nomatch*" 
 | foreach mymatch [ eval test = if(searchmatch("&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;"),"yes","no")]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result is too "yes", because it's blank. My version 7.3.0&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8709i27D513D5885F2E5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 21:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477725#M192744</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-18T21:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477726#M192745</link>
      <description>&lt;P&gt;&lt;CODE&gt;The goal is to compare a lot of _raw with multiples patterns in my lookup for monitoring log.&lt;/CODE&gt;&lt;BR /&gt;
use &lt;CODE&gt;lookup(wildcard)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html"&gt;https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But why do you need to search the log itself?&lt;BR /&gt;
it is better to extract like &lt;CODE&gt;msg&lt;/CODE&gt; field and compare these.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 22:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477726#M192745</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-18T22:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477727#M192746</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html"&gt;https://answers.splunk.com/answers/52580/can-we-use-wildcard-characters-in-a-lookup-table.html&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But why do you need to search the log itself?&lt;BR /&gt;
it is better to extract like msg field and compare these&lt;/P&gt;

&lt;P&gt;@to4kawa &lt;/P&gt;

&lt;P&gt;Because in the lookup, the pattern is in splunk format with "OR" "NOT" "AND" (operator) not only wildcard like this "*"&lt;BR /&gt;
i've the index, the sourcetype and the pattern in splunk format and others fields , i put a "join" in my spl on index and sourcetype for every eventlog and after i want test dynamically all  patterns  for fill every fields for ITSI app.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 22:59:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477727#M192746</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-18T22:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477728#M192747</link>
      <description>&lt;P&gt;foo.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sample
A OR b
*foo
bar
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yours [ | inputlookup foo.csv | table sample | return 1000 $sample]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can do it like that. &lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 01:36:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477728#M192747</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-19T01:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477729#M192748</link>
      <description>&lt;P&gt;@to4kawa &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=yours [ | inputlookup foo.csv | table sample | return 1000 $sample]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i already do that in the root search . But after in the same lookup , i've a description , severity, order, etc..&lt;BR /&gt;
 how i can connect the matches events with the spl pattern in the  lookup for output the other fields without use map command ? &lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 08:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477729#M192748</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-19T08:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477730#M192749</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=sample
| lookup foo.csv host OUTPUT description
| lookup foo.csv user OUTPUT severity
| lookup foo.csv bar OUTPUT baz
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is sample. &lt;CODE&gt;lookup&lt;/CODE&gt; can use it again and again.&lt;BR /&gt;
&lt;CODE&gt;inputlookup&lt;/CODE&gt; is same.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 08:53:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477730#M192749</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-19T08:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477731#M192750</link>
      <description>&lt;P&gt;@to4kawa &lt;/P&gt;

&lt;P&gt;The ID is the pattern in SPL, it's for that  i need a dynamically searchmatch that can indicate with what pattern spl the  event _raw match for connect after with the lookup.&lt;/P&gt;

&lt;P&gt;but i can't pass to the function searchmatch a field value.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 12:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477731#M192750</guid>
      <dc:creator>Testeur971</dc:creator>
      <dc:date>2020-04-19T12:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass argument (dynamically) to searchmatch function without use map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477732#M192751</link>
      <description>&lt;P&gt;I see what you want. but I don't know the details ,logs , lookups.&lt;BR /&gt;
I can't help and make SPL without these.&lt;/P&gt;

&lt;P&gt;You don't provide these, so I think you'll write the SPL yourself.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 21:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-pass-argument-dynamically-to-searchmatch-function-without/m-p/477732#M192751</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-19T21:33:22Z</dc:date>
    </item>
  </channel>
</rss>

