Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Enterprise Tools / March 2004

Tip: Looking for answers? Try searching our database.

Filter events, configure filter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
B.Hoffmann - 10 Feb 2004 11:28 GMT
Hi everyone,

im looking for best practices for filtering EIF/LoggingBlock events and for
operating an instrumented app.
I know the structure of the EIF config file. The way I use it now is to
define event sources for all important components of my app (ex.
DataLayerComponent1, DataLayerComponent2, BusinessLayerComp1... Winclient,
Webclient etc).
But this is not enough. I want to configure which events are logged in
following ways: Event Type, Source, Level, Property Values.
Ex. only log messages from Component1 that are issued by user X (property of
the event) or which contains a searchstring.
I already created my own schema. I added several properties to common, error
and some other events.
Later there will be an admin who wants to click some categories, filters,
searchstring - who simply wants to granular configure which events are
logged (and in my case going in the database).
The next step is to create an wrapper for the configuration api to supply
the admins with an easy config gui....
After this he analyzes the logged data. But the first step is to configure
the amount of data that is being logged.

/Bernd
David Keogh [MSFT] - 19 Feb 2004 18:59 GMT
Bernd, apologies it has taken this long to reply to your question.  Let me
answer some of this inline...

David Keogh [MSFT]

--------------------
| Reply-To: "B.Hoffmann" <hoffmann@REMOVEmicom-medicare.de>
| From: "B.Hoffmann" <hoffmann@REMOVEmicom-medicare.de>
[quoted text clipped - 13 lines]
| Ex. only log messages from Component1 that are issued by user X (property of
| the event) or which contains a searchstring.

There is good news and bad news here.  EIF doesn't provide the ability to
filter in the EnterpriseInstrumentation.config file by event property
value.  However, if you don't mind doing this filtering downstream, you can
of course create a WMI subscription which filters based on specific event
properties using standard WQL (WMI query language).

The other way you could do this is to wrap the place you fire the event in
an IF block, testing for a specific user value and only firing the event if
you have a match.  Unfortunately, unless you do this carefully, it's
hard-coded in your application.  If you drive this from configuration, it
could impose a significant performance penalty unless you are very careful
about how you cache this info.  This is one reason why we only enabled
filtering in EIF based on the kind of event, not down to the level of
specific event property values.

| I already created my own schema. I added several properties to common, error
| and some other events.
[quoted text clipped - 5 lines]
| After this he analyzes the logged data. But the first step is to configure
| the amount of data that is being logged.

This makes sense to me.  Many of our customers have used our configuration
API, either within scripts, or GUI consoles as you describe.  What you can
often do is define multiple filters, each of which represent a particular
"logging level" or amount of information being published.  Then, your
scripts/consoles can simply bind to or unbind from each filter in order to
change the amount of information which is logged.

| /Bernd
B.Hoffmann - 02 Mar 2004 11:14 GMT
Thank you for this information.

What I try now is the following. Maybe somebody has suggestions for this
approach..

In the BaseEvent i check the EventSource.Parameters and filter events
depending on property values. This is done by doing a regular expression
check with RegEx.IsMatch(<property value>,<regular expression from eif
config>).

The entry in the EnterpriseInstrumentation.config could be (this checks
occurence of String1 OR String2 in the property MyProperty, if true the
event is send to the configured sinks):

<eventSource name="MySource" type="softwareElement"
internalExceptionHandler="report">
     <eventSourceParameter name="MyProperty" value="String1|String2" />
</eventSource>

If the Reg. Expr matches then PrepareForSerialization can return true.
Otherwise false.

Im doing the check with something like this (is not yet completed)

private Boolean IsEventFiltered(EventSource eventSource)
 {
  bool bIsFiltered = true;
  foreach(Object oKey in eventSource.Parameters.Keys)
  {
   bIsFiltered = IsPropertyFiltered(this.GetType(),
oKey.ToString(),eventSource.Parameters[oKey].ToString());
   if(!bIsFiltered) return false;
  }
  return bIsFiltered;
 }

 private Boolean IsPropertyFiltered(Type poType, string psPropertyName,
string psFilter)
 {
  try
  {
   string sPropertyValue = poType.InvokeMember(psPropertyName,
    BindingFlags.DeclaredOnly |
    BindingFlags.Public |
    BindingFlags.NonPublic |
    BindingFlags.Instance |
    BindingFlags.GetProperty,
    null, this, null).ToString();
   return
System.Text.RegularExpressions.Regex.IsMatch(sPropertyValue,psFilter);
  }
  catch
  {
   return true;
  }
 }

moi moi
Bernd
Mike Hayton [MS] - 09 Mar 2004 21:30 GMT
I think the approach is fine.
The only comment is that I would remove the call to InvokeMember() and hard
code the getting of the property values.

InvokeMember() is extremely slow - so you'll be getting a big performance
hit at this point.
You might want to check out caching the RegEx objects as well.

Cheers

Mike

--------------------
| Thank you for this information.
|
[quoted text clipped - 55 lines]
| moi moi
| Bernd

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.