Home > SQL Server Tips > Data Warehousing and Business Intelligence > Manage traces in SQL Server 2005 Analysis Services with XMLA commands
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATA WAREHOUSING AND BUSINESS INTELLIGENCE

Manage traces in SQL Server 2005 Analysis Services with XMLA commands


Baya Pavliashvili
07.03.2008
Rating: --- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


As I discussed in a previous tip, you can use SQL Server Profiler to monitor, troubleshoot and tune Microsoft Analysis Services (MSAS) 2005. If you only need this tool occasionally, then using SQL Profiler's graphical interface for starting, changing and stopping traces will suffice.

If you're managing numerous instances of MSAS, then the better option might be to automate your tracing by using XMLA commands. You can submit XMLA commands to Analysis Services through SQL Server Management Studio or through the ASCMD.exe utility. In this tip I'll demonstrate how to use XMLA to manage traces in SQL Server 2005 Analysis Services.

Creating, altering and deleting traces

You can use CREATE … TRACE command to start a new trace. The command allows specifying trace identifier, its name, location where the log files (with .TRC extension) will be saved, and it defines events and columns you wish to monitor with your trace. Trace identifier must be unique on the current instance of Analysis Services. You can grab the basic syntax of the statement directly from SQL Profiler. The full statement looks similar to the following:

[IMAGE] (Click here to download script.)

Note the LogFileSize and LogFileRollover tags. The former specifies the maximum size of each .trc file; the latter advises MSAS whether it should start a new file when the existing file reaches its maximum size. If LogFileRollover is set to 1, MSAS will create a new file and append a sequence number to its name, once the maximum log file size is reached. Otherwise, the trace will be quietly stopped as soon as the log file reaches its maximum size. The AutoRestart tag advises MSAS whether to start the trace each time the service is started. Although useful, ...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
SQL Server Business Intelligence (BI) and Data Warehousing
Using the Pivot transformation in SQL Server Integration Services
DBA career paths could lead to business intelligence
Are data warehouses made for the cloud?
Q&A: Business intelligence gets a facelift in SQL Server 2008 R2
Project Gemini gets a new name, Madison earns buzz
Speed up reports in SQL Server Reporting Services with caching
Data Transformation Services vs. SSIS: The key differences
Using package configurations in SQL Server Integration Services (SSIS)
How SQL Server 2008 components impact SharePoint implementations
Achieving high availability and disaster recovery with SharePoint databases

XML in SQL Server
Processing XML files with SQL Server functions
Top 10 SQL Server development tips of 2008
Create a computed column in SQL Server using XML data
Create DDL table in SQL Server 2005 to audit DDL trigger activity
Retrieve XML data values with XQuery in SQL Server 2005
XML data type in SQL Server 2005 vs. VARCHAR (MAX)
T-SQL commands vs. XML AUTO in SQL Server
Basic Transact-SQL programming constructs: 15 tips, 15 minutes
T-SQL identifiers
Character string data types

Microsoft SQL Server 2005
End of life comes for SQL Server 2005 SP2, 2008
SQL Server Reporting Services Fast Guide
SQL Server Service Broker Tutorial and Reference Guide
Tips for tuning SQL Server 2005 to improve reporting performance
SQL Server consolidation: Why it's an optimization technique
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Enforcing data integrity in a SQL Server database
SSIS error message due to installation problem on SQL Server 2005
Should you upgrade to SQL Server 2005 or SQL Server 2008?
Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
Microsoft SQL Server 2005 Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
data aggregation  (SearchSQLServer.com)
data preprocessing  (SearchSQLServer.com)
data warehouse  (SearchSQLServer.com)
FileMaker  (SearchSQLServer.com)
GIS  (SearchSQLServer.com)
MOLAP  (SearchSQLServer.com)
pivot table  (SearchSQLServer.com)
Quiz: SQL Server 2000  (SearchSQLServer.com)
SQL  (SearchSQLServer.com)
T-SQL  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


if you're not careful, this option could easily cause problems.

On a busy server, Analysis Services traces can grow large very quickly, particularly if you're monitoring numerous detailed events, such as a "Query Subcube Verbose" event. If you allow such trace to restart each time MSAS service is started, you could soon rut out of disk space on a drive where you store the trace files. If you advise MSAS not to restart the trace, the trace could be stopped either explicitly by issuing the DELETE command or implicitly by stopping the service. The Filter tag allows you to specify criteria for including or excluding events in the trace. For example, the sample trace above includes only those events that have duration of 100 milliseconds or more. It also excludes any events associated with a particular SQL Server Profiler trace.

Once you submit the CREATE command to Analysis Services instance, the trace will start recording events – unlike Profiler's graphical interface XMLA, which doesn't require a "start trace" command.

If you change your mind after creating your trace and want to modify the trace definition, you can exploit the ALTER command. For example, we could use the following command to set auto restart attribute to false. Keep in mind that although you might wish to change only one attribute of the trace, you must still include the rest of the tags with the ALTER statement:

[IMAGE] (Click here to download script.)

If you want to stop the trace, use the DELETE command, which has a fairly straightforward syntax – you only have to specify the identifier of a previously created trace, as shown here:

[IMAGE](Click here to download script.)

This statement stops the trace but does not delete .trc files. You can manually delete these files once you've reviewed them.

Reviewing current traces

What if you want to delete the trace you created several weeks ago with the auto restart option, but you've forgotten the identifier for this trace? Don't worry, you can run DISCOVER_TRACES command, like the following statement, to retrieve traces currently running on your analysis server:

[IMAGE](Click here to download script.)

In addition to the XSD schema (which is irrelevant for the purposes of this tip), the command above returns the following output:

[IMAGE](Click here to download script.)

This output shows three traces currently executing on the given Analysis Services instance – Flight Recorder trace, sample trace I just created and a trace started using SQL Profiler. Flight Recorder is a default trace started automatically when MSAS service starts. Using out-of-the-box configuration, this trace collects minimal troubleshooting information; if you need this trace to collect additional information, edit the flightrecordertracedef.xml file found in the "bin" folder of Analysis Services' installation directory. If you configure Analysis Services to log MDX queries into a SQL Server database, you will notice an additional internal MSAS trace created specifically for query logging. If I were to rerun the same DISCOVER_TRACES command as before, I would see the following row for the query log trace:

[IMAGE]
(Click here to download script.)

Regardless of how the trace is created, you can review its output using SQL Profiler. Once you open the trace file, you can save its contents into a SQL Server table for more detailed analysis.

Choosing appropriate events and columns to trace

How does one go about specifying appropriate event and column identifiers in CREATE or ALTER trace statements? Unfortunately, column and event identifiers aren't documented. However, as usual, we can ask our dear friend SQL Profiler to help. Start two traces within SQL Profiler, one with the default events and columns, the second one with the events and columns you wish to monitor with traces you'll create through XMLA. Don't forget to set any desired filters and order output columns to your liking. Then examine the CREATE statement that was sent to the first SQL Profiler window when you created the second trace. Indeed the effort of memorizing the column and event identifiers is unnecessary; you can simply copy and paste event and column identifiers from SQL Profiler, then adjust as you see fit within XMLA.

ABOUT THE AUTHOR:   

[IMAGE]Baya Pavliashvili is a database consultant helping his customers develop highly available and scalable applications with SQL Server and Analysis Services. Throughout his career he has managed database administrator teams and databases of terabyte caliber. Baya's primary areas of expertise are performance tuning, replication and data warehousing. He can be reached at baya@bayasqlconsulting.com.
Copyright 2008 TechTarget


Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts