Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring .NET ASP.NET Applications

I have a number of applications running on top of ASP.NET I want to monitor. The main things I care about are:

  • Exceptions: We currently some custom code which will email us when an exception occurs. If the application is failing hard it will crash our outlook... I know (and use) elmah which partly solves the problem however it is still just a big table of exceptions with a pretty(ish) UI. I want something that makes sense of all of these exceptions (e.g. groups exceptions, alerts when new ones occur, tells me what the common ones are that I should fix, etc)

  • Logging: We currently log to files which are then accessible via a shared folder which dev's grep & tail. Does anyone know of better ways of presenting this information. In an ideal world I want to associate it with exceptions.

  • Performance: Request times, memory usage, cpu, etc. whatever stats I can get

I'm guessing this is probably going to be solved by a number of tools, has anyone got any suggestions?

like image 711
James Hollingworth Avatar asked Jan 05 '11 22:01

James Hollingworth


2 Answers

You should take a look at Gibraltar not used it myself but looks very good! Also works with nLog and log4net so if you use those you are in luck!!

like image 52
caveman_dick Avatar answered Sep 19 '22 10:09

caveman_dick


Well, we have exactly the same current solution. Emails upon emails litter my inbox and mostly get ignored. Over the holidays an error caused everyone in dev to hit their inbox limit ;)

So where are we headed with a solution?

  1. We already generate classes for all our excpetions, they rarely get used from more than one place. This was essentially step one, but we started the code base this way.
  2. We modified the generator to create unique HRESULT values for all exceptions.
  3. Again we added a generator to create a .MC message resource file for every exception.
  4. Now every exception can write itself to the Windows Event Log, and thus we removed all emails etc, and rely on the event log.
  5. Now with an event log full of information, including unique message codes and parameters for each exception, we can use off-the-shelf tools to aggregate, monitor, and alert.

The exception generator (before modifications above) is located here:

  • http://csharptest.net/browse/src/Tools/Generators

It integrates with visual studio by replacing the ResX generator with this:

  • http://csharptest.net/browse/src/Tools/CmdTool

I have not yet published the MC generator, or the HRESULT generation; however, it will be available in the above locations when I get the time.

-- UPDATE --

All the tools and source are now available online for this. So where do I go from here?

  1. Download the source or binaries from: http://code.google.com/p/csharptest-net/
  2. Take a look at the help for CmdTool.exe Visual Studio Integration
  3. Then review the help on Generators for ResX and MC files, there are several ways to generate MC files or complete message DLLs from ResX files. Pick the approach that fits you best.
  4. Run CmdTool.exe REGISTER to register the tool with Visual Studio
  5. Create a ResX file as normal, then change the custom tool to CmdTool
  6. You will need to add some entries to the resx file. At minimal create the following:
    • ".AutoLog" = true
    • ".NextMessageId" = 1
    • ".EventSource" = "HelloWorld"
    • "MyCustomException" = "Some exception text"
    • Other settings exampled by the NUnit: http://csharptest.net/browse/src/Tools/Generators/Test/TestResXAutoLog.cs#80
  7. Now you should have an exception class being generated that writes log events. You will need to build the MC file as a pre/post build action with something like:
    • CSharpTest.Net.Generators.exe RESXTOMESSAGEDLL /output=MyCustomMessages.dll /input=TheProjectWithAResX.csproj
  8. Lastly, you need to register it, run the framework's InstallUtil.exe MyCustomMessages.dll

That should get you started until I get time to document it all.

like image 23
csharptest.net Avatar answered Sep 21 '22 10:09

csharptest.net