<?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: Is there an alternative to using regex in my search for better performance? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220984#M64936</link>
    <description>&lt;P&gt;From quickly scanning through some documentation, it seems that "rex" is actually a "distributed streaming" command which means it can be run on the indexer itself so you don't have to worry about innefficiencies with map-reduce.&lt;/P&gt;

&lt;P&gt;However, to better structure your search you can provide all the "known search tokens" to your search and you could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x test @ | regex email="test@.*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What this does is it passes the known "search tokens" of "test" and "@" as search tokens to the indexer which allows the indexer to pull out only events with those two tokens &lt;STRONG&gt;anywhere in the event&lt;/STRONG&gt;. THEN the "rex" will do the specific pattern match. I dont think doing the rex on it's own will allow the indexer to search for events where ONLY "test" and "@" are present. It will have to search ALL events first. &lt;/P&gt;

&lt;P&gt;So the search above reduces inefficiencies because it puts everything that &lt;STRONG&gt;you know you need&lt;/STRONG&gt; before the first pipe and then allows the rex to do the pattern matching afterwards. &lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 16:30:29 GMT</pubDate>
    <dc:creator>jdunlea</dc:creator>
    <dc:date>2016-06-16T16:30:29Z</dc:date>
    <item>
      <title>Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220982#M64934</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;

&lt;P&gt;After reading some answers, I see that if I use regex for searching events corresponding to a pattern, it will take a lot of time as Splunk reads all events from disk.&lt;/P&gt;

&lt;P&gt;For example: I use &lt;CODE&gt;index=X email="test@*"&lt;/CODE&gt;, it will be so much faster than &lt;CODE&gt;index=X | regex email="test@.*"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;So my question is beside the &lt;CODE&gt;*&lt;/CODE&gt; , can I use another regex term in the default search without using regex that provides the same performance as original search. &lt;/P&gt;

&lt;P&gt;For ex: &lt;BR /&gt;
&lt;CODE&gt;index=X email="test@[a-z]+.com"&lt;/CODE&gt; ? &lt;BR /&gt;
&lt;CODE&gt;index=X email="test@[0-9]*.com"&lt;/CODE&gt; ?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 14:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220982#M64934</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-16T14:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220983#M64935</link>
      <description>&lt;P&gt;Regular expressions are not supported in base search (only wild card */ asterisk ). I would suggest to add some filters in the base search using wildcard and then use regex to do to the point filter (hybrid of both type of filter).&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:24:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220983#M64935</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-16T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220984#M64936</link>
      <description>&lt;P&gt;From quickly scanning through some documentation, it seems that "rex" is actually a "distributed streaming" command which means it can be run on the indexer itself so you don't have to worry about innefficiencies with map-reduce.&lt;/P&gt;

&lt;P&gt;However, to better structure your search you can provide all the "known search tokens" to your search and you could do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x test @ | regex email="test@.*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What this does is it passes the known "search tokens" of "test" and "@" as search tokens to the indexer which allows the indexer to pull out only events with those two tokens &lt;STRONG&gt;anywhere in the event&lt;/STRONG&gt;. THEN the "rex" will do the specific pattern match. I dont think doing the rex on it's own will allow the indexer to search for events where ONLY "test" and "@" are present. It will have to search ALL events first. &lt;/P&gt;

&lt;P&gt;So the search above reduces inefficiencies because it puts everything that &lt;STRONG&gt;you know you need&lt;/STRONG&gt; before the first pipe and then allows the rex to do the pattern matching afterwards. &lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220984#M64936</guid>
      <dc:creator>jdunlea</dc:creator>
      <dc:date>2016-06-16T16:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220985#M64937</link>
      <description>&lt;P&gt;your answer is just right for some specific cases. if i search for "email="test.*&lt;A href="mailto:hello@"&gt;hello@&lt;/A&gt;.*", the search with the tokens like "test hello @" will return nothing.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 10:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220985#M64937</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-17T10:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220986#M64938</link>
      <description>&lt;P&gt;thank for your reply, only * is supported in base search ( cannot use ?, [0-9], or [a-z] ), is it right ?&lt;BR /&gt;
I ask this type of question because i did not where the doc of splunk mentions all regular expressions that could be used in base search.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 10:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220986#M64938</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-17T10:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220987#M64939</link>
      <description>&lt;P&gt;Well, that is only true if "test" and "hello" are not &lt;STRONG&gt;individual tokens&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;I.E. If I search as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X test hello @ | rex email="test.*hello@.*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will NOT return any results &lt;STRONG&gt;IF&lt;/STRONG&gt; the data you are looking for is something like &lt;/P&gt;

&lt;P&gt;"&lt;A href="mailto:testworldhello@something.com"&gt;testworldhello@something.com&lt;/A&gt;"&lt;/P&gt;

&lt;P&gt;This is because you cannot search for "test" or "hello" on their own if they are just a part of a larger token (testworldhello). &lt;/P&gt;

&lt;P&gt;The search above WILL return results if the data looks like:&lt;/P&gt;

&lt;P&gt;"&lt;A href="mailto:test.world-hello@something.com"&gt;test.world-hello@something.com&lt;/A&gt;"&lt;/P&gt;

&lt;P&gt;The main point I am trying to make is that to create better search efficiency you can provide as many &lt;STRONG&gt;actual tokens&lt;/STRONG&gt; as you can, up front. Tokens are separated by things like dots, dashes, slashes, etc.&lt;/P&gt;

&lt;P&gt;To see how tokens are identified and separated in Splunk you can research &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/Segmentersconf"&gt;segmenters.conf&lt;/A&gt; which shows you how Splunk breaks out tokens in any event. &lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 13:12:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220987#M64939</guid>
      <dc:creator>jdunlea</dc:creator>
      <dc:date>2016-06-17T13:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220988#M64940</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Have you try to extract the fields of the email like     @&lt;/P&gt;

&lt;P&gt;Then if you make a search using these fields it should be faster like  &lt;/P&gt;

&lt;P&gt;index=aaaa field1=test field2=google.com&lt;/P&gt;

&lt;P&gt;Hope i help you&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 13:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220988#M64940</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2016-06-17T13:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220989#M64941</link>
      <description>&lt;P&gt;The base search provides all the options a "| search" command provides (actually they are the same, it's hidden in base search). It basically uses logical expression (not regular expressions). See more info here&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Search#Usage"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Search#Usage&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 13:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220989#M64941</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-17T13:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220990#M64942</link>
      <description>&lt;P&gt;Thank you for your information, now i  know only * is supported. I hope splunk would support more wild card in the future version &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; , for ex: "?" or "|".&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 14:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220990#M64942</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-17T14:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220991#M64943</link>
      <description>&lt;P&gt;it does not actually respond to my question because if field 1 contains un regular expression that is not "*" wild card, you have to use regex command and ... splunk reads all events for the comparision.  I think the temporary solution maybe use the hydrid solution like the answer of @somesoni2 above&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 14:27:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220991#M64943</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-17T14:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220992#M64944</link>
      <description>&lt;P&gt;i got your point, but that's the reason i asked this question, i want to know if splunk supports more than the asterisk wild card in the base search. Thank you in anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 14:29:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220992#M64944</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2016-06-17T14:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220993#M64945</link>
      <description>&lt;P&gt;Ah I see. Looks like you got your answer above! Good luck! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2016 14:32:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220993#M64945</guid>
      <dc:creator>jdunlea</dc:creator>
      <dc:date>2016-06-17T14:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an alternative to using regex in my search for better performance?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220994#M64946</link>
      <description>&lt;P&gt;Ok regards &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 09:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-alternative-to-using-regex-in-my-search-for-better/m-p/220994#M64946</guid>
      <dc:creator>jmallorquin</dc:creator>
      <dc:date>2016-06-20T09:04:48Z</dc:date>
    </item>
  </channel>
</rss>

