Using RegEx in Subscription Criteria
Using RegEx in Subscription Criteria Hello I want to use RegEx expression for filtering in my Subscription criteria, as follows: Let say all the monitor I created start with same set of characters i.e. "My Monitor" Therefore I have several monitors called My Monitor ABC My Monitor 123 My Monitor XYZ Therefore as part of the Subscription Criteria, under "with a specific name" I currently have My Monitor% The % meaning any one or more characters. That works find I receive notifications for alerts from all of the monitors with the above names. Now what I want to do is keep this one subscription criteria but exclude notifications from say My Monitor 123. I still want to receive notifications from the other two monitors, therefore I was thinking this is a case for RegEx First question is can I use RegEx in the criteria "with a specific name" field? I guess I am already doing the with the % however, I believe that is an SQL expression rather than a true RegEx expression? The following blog has some detailed information http://social.technet.microsoft.com/Forums/en-US/operationsmanagergeneral/thread/ac0bf65f-f562-4f8c-b624-5fbe7ee2e795/ I am not clear if this would work in my case, for example it states the ^ character is used to denote NOT. Based on this I was thinking about changing the above My Monitor% To My Monitor%[^123] Will the above work, is it the correct syntax? Any advise, most welcome Thanks you all Ernie
June 27th, 2011 12:27pm

for regex % doesnt mean any one or more it just means %. "." means any char .* means any repetitions of any char. ^ means beginning of a line, so dont use that. But it depends on where u need to use it exactly. At some places you need to SQL style expression where at other places you need to use regex (which doesnt really have a very easy implementation to start with). You just gotta love the constistency used in scom!Rob Korving http://jama00.wordpress.com/
Free Windows Admin Tool Kit Click here and download it now
June 27th, 2011 1:22pm

Hi Rob Thanks for the reply and clarification. I guess the field I am interested in, "with a specific name" which is under Subscription Criteria uses SQL type filtering (from what you said above). As when you click on it to enter a value there is a little help which states you can use SQL wildcard characters like % and _ for example. As you stated above "At some places you need to SQL style expression where at other places you need to use regex" I assume I can therefore not use RegEx expressions. If that is the case, maybe there is an equivalent for SQL i.e. a NOT operator Any idea how to specify and inline NOT in an SQL filer? Thanks Ernie
June 27th, 2011 1:52pm

http://msdn.microsoft.com/en-us/library/ms179859.aspx In terms of SQL your query is NOT LIKE 'My Monitor 123%' If you use My Monitor [^1][^2][^3]%, it will not match for example "My Monitor 222".
Free Windows Admin Tool Kit Click here and download it now
June 27th, 2011 3:40pm

Thanks for the input Yury I will try your suggestion My Monitor [^1][^2][^3]%, in the UI of the SCOM Console, Administration Space when I am setting up the Subscription Criteria and let you know how I get on Thanks again Ernie
June 27th, 2011 5:11pm

Ernie, please be aware that this expression is not versatile. My Monitor [^1][^2][^3]% My Monitor ABC - pass My Monitor 123 - no pass My Monitor XYZ - pass My Monitor 222 - no pass My Monitor XY3 - no pass So this is more a workaround than a 100% solution.
Free Windows Admin Tool Kit Click here and download it now
June 27th, 2011 8:48pm

Why not just use "created by specific rules and monitors"? Easy enough to filter if you have them in one MP or the name starts with My Monitor. Select and add.
June 27th, 2011 9:29pm

Hello Yury, Thanks again for your help. Your solution worked, however with a slight difference as I discovered something else while testing. Basically the example above My Monitor [^1][^2][^3]% Only takes into account the First character of the word/phrase for example, using the above filer, the results were My Monitor ABC - pass My Monitor 123 - no pass My Monitor XYZ - pass My Monitor 222 - pass My Monitor XY3 - pass I therefore had to add an _ as part of the filter meaning one character, therefore using the above example if I want to block My Monitor 123 My filter would be as follows My Monitor [^1][^_2][^__3]% i.e. 1 being the first character, 2 being the second character by placing any single character in front of it using the _ then 3 being the third character by placing and two characters in from of it by using two _ characters i.e. __ Thanks again, I could not of figured it out without your help Ernie
Free Windows Admin Tool Kit Click here and download it now
June 27th, 2011 11:53pm

Ernie, thanks for the update - and glad it helped you find the right direction!
June 28th, 2011 8:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics