The following is the code used on the roles to have the Azure Cloud collect the data and publish it to the Azure Storage Tables:

        public override bool OnStart()
        {
            DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error;
            diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            diagConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
            diagConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            diagConfig.WindowsEventLog.DataSources.Add("Application!*");
            diagConfig.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Warning;
            diagConfig.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            diagConfig.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
            diagConfig.PerformanceCounters.BufferQuotaInMB = 1;

            AddPerformanceCounter(diagConfig, @"\Processor(_Total)\% Processor Time");
            AddPerformanceCounter(diagConfig, @"\.NET CLR Memory(_Global_)\# Bytes in all Heaps");
            AddPerformanceCounter(diagConfig, @"\ASP.NET Applications(__Total__)\Requests/Sec");
            AddPerformanceCounter(diagConfig, @"\ASP.NET Applications(__Total__)\Cache Total Hit Ratio");
            AddPerformanceCounter(diagConfig, @"\ASP.NET\Requests Queued");
            AddPerformanceCounter(diagConfig, @"\ASP.NET\Requests Rejected");

            DiagnosticMonitor.Start("DiagnosticsConnectionString", diagConfig);

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            RoleEnvironment.Changing += RoleEnvironmentChanging;

            Trace.TraceWarning("Web Application Started");

            return base.OnStart();
        }

        private static void AddPerformanceCounter(DiagnosticMonitorConfiguration diagConfig, string counterName)
        {
            PerformanceCounterConfiguration cpuCounter = new PerformanceCounterConfiguration();
            cpuCounter.SampleRate = TimeSpan.FromMinutes(1);
            cpuCounter.CounterSpecifier = counterName;

            diagConfig.PerformanceCounters.DataSources.Add(cpuCounter);
        }

Last edited Feb 11, 2010 at 8:37 PM by CharlesTurano, version 1

Comments

No comments yet.