<?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 create an alert based on a field value regex pattern? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344729#M102122</link>
    <description>&lt;P&gt;Thank you again Acharlieh.&lt;/P&gt;

&lt;P&gt;I do like your idea about not matching a regex pattern.&lt;/P&gt;

&lt;P&gt;I think I will ask this specific question in the future.&lt;/P&gt;</description>
    <pubDate>Sun, 15 Apr 2018 01:39:20 GMT</pubDate>
    <dc:creator>Log_wrangler</dc:creator>
    <dc:date>2018-04-15T01:39:20Z</dc:date>
    <item>
      <title>How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344721#M102114</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I am looking for the best way to alert when a field value is not within a normal input range?&lt;/P&gt;

&lt;P&gt;For example, I have a field called 'Account_ID" and the only normal value should be 1 to 5 digits long, like 99999.&lt;/P&gt;

&lt;P&gt;I want to create an alert that triggers if Account_ID = is not a number but contains any characters other than numbers or greater than 5 digits.&lt;/P&gt;

&lt;P&gt;For example  Account_ID = 87347  (good)  Account_ID = 848/'A$  (bad - alert)  or Account_ID = 9938848994994 (bad)&lt;/P&gt;

&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:05:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344721#M102114</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2020-09-29T19:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344722#M102115</link>
      <description>&lt;P&gt;hello @Log_wrangler&lt;/P&gt;

&lt;P&gt;try out the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1 
| eval Account_ID = "2345564,12345,9999999999,342A@,12345$%^"
| makemv delim="," Account_ID
| mvexpand Account_ID
| eval char_count = len(Account_ID)
| eval num_or_string = if(isnum(Account_ID),"Number","String")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;from there you can set your alert: &lt;CODE&gt;| where char_count &amp;gt; 5 ....&lt;/CODE&gt; etc&lt;BR /&gt;
see also screen shot:&lt;BR /&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/4789iF0022E35ED0BD339/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, 14 Apr 2018 13:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344722#M102115</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-04-14T13:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344723#M102116</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/75933"&gt;@Log_wrangler&lt;/a&gt;, try the following eval &lt;CODE&gt;|  eval validation_result= if((!isnum(Account_ID)) OR (isnum(Account_ID) AND (len(Account_ID)&amp;lt;=0 OR len(Account_ID)&amp;gt;5)),"bad","good")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Following is a run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Account_ID="87347,848/'A$,9938848994994" 
| makemv Account_ID delim="," 
| mvexpand Account_ID 
| eval validation_result= if((!isnum(Account_ID)) OR (isnum(Account_ID) AND (len(Account_ID)&amp;lt;=0 OR len(Account_ID)&amp;gt;5)),"bad","good")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:02:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344723#M102116</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T19:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344724#M102117</link>
      <description>&lt;P&gt;It sounds like you are looking for the &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.3/SearchReference/Regex"&gt;regex command&lt;/A&gt;. Using this you will filter out ( &lt;CODE&gt;!=&lt;/CODE&gt; ) events whose account_id field matches your regular expression pattern of what makes a valid account id, and then alert if any events are left. &lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 13:15:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344724#M102117</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2018-04-14T13:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344725#M102118</link>
      <description>&lt;P&gt;Thank you (everyone) for the replies.&lt;/P&gt;

&lt;P&gt;What I would like to do is run a search (for example daily) that returns a list of all the Account_IDs and checks for bad Account_IDs and returns a list of Bad_IDs.    &lt;/P&gt;

&lt;P&gt;I was thinking about using a != regex match but will that slow performance?&lt;/P&gt;

&lt;P&gt;any suggestions on how to write the eval Account_ID != regex then list new field bad_ID?&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:05:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344725#M102118</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2020-09-29T19:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344726#M102119</link>
      <description>&lt;P&gt;I like your query, however there is a problem, if the Account_ID value &amp;lt;=0 , like 000 I want that to be "bad', however I will accept your answer because it is mostly successful.   I am looking for the syntax for the eval statement to look at number value instead of length.   Please share if you know it.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 01:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344726#M102119</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-04-15T01:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344727#M102120</link>
      <description>&lt;P&gt;IF there is a better way please let me know, but here is what I built off your base code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A sourcetype=A_logs |  eval Account_ID_format = if((!isnum(Account_ID)) OR (Account_ID=0) OR (isnum(Account_ID) AND (len(Account_ID)&amp;gt;5)),"bad","good") | search Account_ID_format = bad | stats values(Account_ID_format) by Account_ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Apr 2018 01:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344727#M102120</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-04-15T01:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344728#M102121</link>
      <description>&lt;P&gt;Thank you for your reply, I chose to follow the first response bc it seemed easier, but you have a good idea too, which I will refer to in the future.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 01:36:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344728#M102121</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-04-15T01:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344729#M102122</link>
      <description>&lt;P&gt;Thank you again Acharlieh.&lt;/P&gt;

&lt;P&gt;I do like your idea about not matching a regex pattern.&lt;/P&gt;

&lt;P&gt;I think I will ask this specific question in the future.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 01:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344729#M102122</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-04-15T01:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an alert based on a field value regex pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344730#M102123</link>
      <description>&lt;P&gt;@Log_wrangler, please try out the following search. I have updated the validation condition, and performing &lt;CODE&gt;tonumber()&lt;/CODE&gt; conversion as a separate step.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=A sourcetype=A_logs 
 | stats count by Account_ID
 | eval Account_ID=tonumber(Account_ID)
 | eval Account_ID_format= if((isnull(Account_ID)) OR ((Account_ID&amp;lt;=0) OR (len(Account_ID)&amp;lt;=0 OR len(Account_ID)&amp;gt;5)),"bad","good")
 | search Account_ID_format = bad
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that I have moved stats up and am performing stats on Good Account Ids as well. But filtering only the bad results in the end. &lt;STRONG&gt;Performing streaming command(eval) on the results of a transforming command (stats) should perform better.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 08:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-an-alert-based-on-a-field-value-regex-pattern/m-p/344730#M102123</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-15T08:52:36Z</dc:date>
    </item>
  </channel>
</rss>

