{"id":76,"date":"2008-09-18T18:27:36","date_gmt":"2008-09-18T23:27:36","guid":{"rendered":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/?p=76"},"modified":"2008-09-18T18:27:36","modified_gmt":"2008-09-18T23:27:36","slug":"how-to-use-mdw-to-collect-analysis-services-2008-performance-counters","status":"publish","type":"post","link":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/76_how-to-use-mdw-to-collect-analysis-services-2008-performance-counters","title":{"rendered":"How to use MDW to collect Analysis Services 2008 performance counters"},"content":{"rendered":"<p>In one of my <a href=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/55_sql-server-2008-management-data-warehouse\" target=\"_blank\">previous blog posts<\/a> I described SQL Server 2008 Management Data Warehouse (MDW) and how it can be used to collect performance information. This post will describe how you can create new MDW data collection sets to\u00a0capture SQL Server Analysis Services (SSAS) 2008 performance counters.<\/p>\n<p>SQL Server 2008 does not have a\u00a0graphical interface to create MDW data collection sets, so the best way to do that is by\u00a0scripting\u00a0an existing system data collection set\u00a0and then changing it. To script an\u00a0existing data collector,\u00a0start SQL Server Management Studio, expand &#8220;Management&#8221;-&gt;&#8221;Data Collection&#8221;-&gt;&#8221;System Data Collection Sets&#8221; folder then right mouse click-&gt; &#8220;Script Data Collection As..&#8221;-&gt;&#8221;Create To&#8221;-&gt;&#8221;New Query Editor Window&#8221;. For my starting point I\u00a0scripted\u00a0the\u00a0data collection set\u00a0&#8220;Server Activity&#8221; and got\u00a0<a href=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post76\/server_activity.txt\" target=\"_blank\">this script<\/a>.<\/p>\n<p><!--more--><\/p>\n<p>The original script collects information from\u00a0two different collector types: &#8220;Generic T-SQL Query Collector Type&#8221; and &#8220;Performance Counters Collector Type&#8221;. For this exercise I removed part of the script related to the first collector type. Then I updated\u00a0the data collection set name and\u00a0replaced\u00a0 the performance counters that I am interested in collecting. All performance counters are listed in\u00a0the string as XML node attributes. Here is example of one counter:<\/p>\n<blockquote><p>&lt;PerformanceCounters Objects=&#8221;Process&#8221; Counters=&#8221;%Processor Time&#8221; Instances=&#8221;sqlservr&#8221; \/&gt;<\/p><\/blockquote>\n<p>For counters you can specify value &#8220;*&#8221; and that will include all counters from\u00a0a specific object. You do not have to specify the &#8220;Instances&#8221; attribute.<\/p>\n<p>For this exercise I selected just a few Analysis Services related counters that I wanted to track.\u00a0I see myself having at least a few SSAS related data collection sets &#8211; for example I would want to have a separate set\u00a0to track cube processing performance that I would run just during nightly cube reprocessing.\u00a0\u00a0<a href=\"http:\/\/www.ssas-info.com\/analysis-services-articles\/58-ssas-2008\/1113-analysis-services-2008-performance-counters\" target=\"_blank\">Here is the list of Analysis Services 2008 performance counters<\/a>\u00a0that you could use to build your data collection sets.<\/p>\n<p>So\u00a0below is the script to create\u00a0a new data collection set\u00a0&#8220;Server Activity SSAS Counters 1&#8221;. This script should be executed in MDW database:<\/p>\n<blockquote><p>Begin Transaction<br \/>\nBegin Try<br \/>\nDeclare @collection_set_id_1 int<br \/>\nDeclare @collection_set_uid_2 uniqueidentifier<br \/>\nEXEC [msdb].[dbo].[sp_syscollector_create_collection_set] @name=N&#8217;Server Activity SSAS Counters 1&#8242;<br \/>\n, @collection_mode=0<br \/>\n, @description=N&#8217;Collects top-level performance indicators for the computer and the Database Engine. Enables analysis of resource use, resource bottlenecks, and Database Engine activity.&#8217;<br \/>\n, @logging_level=0, @days_until_expiration=14<br \/>\n, @schedule_name=N&#8217;CollectorSchedule_Every_15min&#8217;<br \/>\n, @collection_set_id=@collection_set_id_1 OUTPUT<br \/>\n, @collection_set_uid=@collection_set_uid_2 OUTPUT<br \/>\nSelect @collection_set_id_1, @collection_set_uid_2<br \/>\nDeclare @collector_type_uid_5 uniqueidentifier<br \/>\nSelect @collector_type_uid_5 = collector_type_uid From [msdb].[dbo].[syscollector_collector_types]<br \/>\n\u00a0Where name = N&#8217;Performance Counters Collector Type&#8217;;<br \/>\nDeclare @collection_item_id_6 int<br \/>\nEXEC [msdb].[dbo].[sp_syscollector_create_collection_item] @name=N&#8217;Server Activity &#8211; SSAS Performance Counters 1&#8242;<br \/>\n, @parameters=N'&lt;ns:PerformanceCountersCollector xmlns:ns=&#8221;DataCollectorType&#8221;&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;Processor&#8221; Counters=&#8221;%Processor Time&#8221; Instances=&#8221;_Total&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;Process&#8221; Counters=&#8221;%Processor Time&#8221; Instances=&#8221;msmdsrv&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;Process&#8221; Counters=&#8221;%Processor Time&#8221; Instances=&#8221;sqlservr&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Connection&#8221; Counters=&#8221;Current connections&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Connection&#8221; Counters=&#8221;Current user sessions&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Memory&#8221; Counters=&#8221;Memory Usage KB&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Storage Engine Query&#8221; Counters=&#8221;Current measure group queries&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Storage Engine Query&#8221; Counters=&#8221;Avg time\/query&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Storage Engine Query&#8221; Counters=&#8221;Aggregation hits\/sec&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Storage Engine Query&#8221; Counters=&#8221;Queries answered\/sec&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:Storage Engine Query&#8221; Counters=&#8221;Total queries answered&#8221; \/&gt;<br \/>\n&lt;PerformanceCounters Objects=&#8221;MSAS 2008:MDX&#8221; Counters=&#8221;Total cells calculated&#8221; \/&gt;<br \/>\n&lt;\/ns:PerformanceCountersCollector&gt;&#8217;<br \/>\n, @collection_item_id=@collection_item_id_6 OUTPUT, @frequency=60<br \/>\n, @collection_set_id=@collection_set_id_1, @collector_type_uid=@collector_type_uid_5<br \/>\nSelect @collection_item_id_6<\/p>\n<p>Commit Transaction;<br \/>\nEnd Try<br \/>\nBegin Catch<br \/>\nRollback Transaction;<br \/>\nDECLARE @ErrorMessage NVARCHAR(4000);<br \/>\nDECLARE @ErrorSeverity INT;<br \/>\nDECLARE @ErrorState INT;<br \/>\nDECLARE @ErrorNumber INT;<br \/>\nDECLARE @ErrorLine INT;<br \/>\nDECLARE @ErrorProcedure NVARCHAR(200);<br \/>\nSELECT @ErrorLine = ERROR_LINE(),<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @ErrorSeverity = ERROR_SEVERITY(),<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @ErrorState = ERROR_STATE(),<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @ErrorNumber = ERROR_NUMBER(),<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @ErrorMessage = ERROR_MESSAGE(),<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 @ErrorProcedure = ISNULL(ERROR_PROCEDURE(), &#8216;-&#8216;);<br \/>\nRAISERROR (14684, @ErrorSeverity, 1 , @ErrorNumber, @ErrorSeverity, @ErrorState, @ErrorProcedure, @ErrorLine, @ErrorMessage);<\/p>\n<p>End Catch;<\/p>\n<p>GO<\/p><\/blockquote>\n<p><a href=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post76\/ssas_counter1.txt\" target=\"_blank\">Here is the link to the text file<\/a> with SQL statements.<\/p>\n<p>After you execute this script, in SSMS you will see\u00a0a new data collection set\u00a0&#8220;Server Activity SSAS Counters 1&#8221;. To\u00a0begin collecting data, you will need to start this new collector (right mouse click, &#8220;Start Data Collection Set&#8221;).<\/p>\n<p>After your custom data collection set is up and running, you have to build custom reports to show data that was collected.\u00a0Creating custom report deserves a separate blog post or even two, as it is not very easy. The best way would be to follow\u00a0the steps that Microsoft did for system MDW reports. I run the profiler to capture how Microsoft does that and found that all data for reports comes back from parameterized stored procedures. For\u00a0this demo, I just quickly created a query to get the captured data and used that in the SSRS report.<\/p>\n<p>Captured performance counter data is stored in the MDW database tables snapshots.performance_counter_values and snapshots.performance_counter_instances. Here is the structure for these tables:\u00a0<\/p>\n<div style=\"width: 396px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" title=\"MDW Peformance counter related tables\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post76\/perf_count_tbl.jpg\" alt=\"MDW Peformance counter related tables\" width=\"386\" height=\"444\" \/><p class=\"wp-caption-text\">MDW Peformance counter related tables<\/p><\/div>\n<p>Microsoft also has a view\u00a0\u00a0snapshots.performance_counters that is a inner join of these two tables. I used that view for my queries. Here is sample of my query:<\/p>\n<blockquote><p>SELECT performance_counter_id<br \/>\n\u00a0, snapshot_id<br \/>\n\u00a0, collection_time &#8212;\u00a0UTC time used!!!<br \/>\n\u00a0, RIGHT(LEFT(CONVERT(varchar, collection_time, 120),10),5) AS CollectionDate<br \/>\n\u00a0, LEFT(RIGHT(CONVERT(varchar, collection_time, 120),8),5) AS CollectionTime<br \/>\n\u00a0, path<br \/>\n\u00a0, performance_object_name<br \/>\n\u00a0, performance_counter_name<br \/>\n\u00a0, performance_instance_name<br \/>\n\u00a0, formatted_value<br \/>\n\u00a0, raw_value_first<br \/>\n\u00a0, raw_value_second<br \/>\n\u00a0 FROM [MDW].[snapshots].[performance_counters]<br \/>\n\u00a0WHERE performance_object_name like &#8216;MSAS 2008:%&#8217;<\/p><\/blockquote>\n<p>Big surprise to me was that you cannot use BIDS 2008 to build custom reports, you have to use Reporting Services with BIDS 2005. Based <a href=\"https:\/\/connect.microsoft.com\/SQLServer\/feedback\/ViewFeedback.aspx?FeedbackID=356519&amp;wa=wsignin1.0\" target=\"_blank\">on this Microsoft connect feedback <\/a>it is by design, but it is quite a big inconvieniece, so I hope Microsoft will fix this in the future. If you\u00a0are building custom reports for SQL Server 2008, please make sure you leave your vote for this connect feedback, as more votes should make Microsoft consider to make this change sooner.<\/p>\n<p>I created a sample dashboard type report just to show 2 SSAS performance counters. Here is screenshot for my dashboard:<\/p>\n<div id=\"attachment_82\" style=\"width: 160px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-content\/uploads\/2008\/09\/ssascountersreport.jpg\"><img aria-describedby=\"caption-attachment-82\" loading=\"lazy\" class=\"size-thumbnail wp-image-82 \" title=\"SSAS Counters MDW report\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-content\/uploads\/2008\/09\/ssascountersreport-150x150.jpg\" alt=\"SSAS Counters MDW report\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-82\" class=\"wp-caption-text\">SSAS Counters MDW report<\/p><\/div>\n<p>RDL code for this report can be downloaded <a href=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post76\/ssas_counters_report.txt\" target=\"_blank\">here<\/a>. After downloading this file, please change the file extension from .txt to .rdl and copy it\u00a0to\u00a0your SQL Server server machine. Then in SSMS you should select\u00a0the data collection set, right mouse click, then &#8220;Reports&#8221;-&gt;&#8221;Custom reports&#8221;-&gt;&#8221;Add Custom Report&#8221; and select the\u00a0rdl file from\u00a0the saved location. You will need to add\u00a0your custom report just once, after that it will appear in the custom report list.<\/p>\n<p>Please note again, that\u00a0the above report is just a sample of how to build custom reports. To show captured SSAS performance counters for a real environment you will need to spend much more time in building\u00a0nicer looking\u00a0reports.<\/p>\n<p>I like MDW because\u00a0this framework provided by Microsoft takes care of data collection, storage and purge and because it is easy to integrate reports into SQL Server Management Studio. I am just waiting from Microsoft (or a third party) for\u00a0a set of data collectors and reports related to Analysis Services.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In one of my previous blog posts I described SQL Server 2008 Management Data Warehouse (MDW) and how it can be used to collect performance information. This post will describe how you can create new MDW data collection sets to\u00a0capture SQL Server Analysis Services (SSAS) 2008 performance counters. SQL Server 2008 does not have a\u00a0graphical [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[10,11,12,21],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":13,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":90,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts\/76\/revisions\/90"}],"wp:attachment":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}