This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Custom Metric - Index Fragmentation

DESCRIPTION

This custom metric will track the fragmentation of an index

METRIC DEFINITION

To create the custom metric, click on Options > Custom Resource Metrics and configure the metric similar to this:

Database Versions: <no limitations>

Display Name: Index Fragmentation

Description: <add your own description>

Category: <add to whatevfer category you like or create a new one>

Units: %

Metric Type: Single Value

Frequency: 900

Timeout: 50

SQL Statement:

Use [Database]

SELECT round(avg_fragmentation_in_percent, 0) FROM sys.dm_db_index_physical_stats(DB_ID(N'Database'), Object_ID(N'Database.Table'), INDEXPROPERTY(OBJECT_ID('Database.Table'), 'Index_Name', 'IndexID'), NULL , NULL)