Percentage of used log space

| 4 Comments | 9,675 views
Categories:

VN:F [1.9.17_1161]
Rating: 4.8/5 (5 votes cast)

This metric measures the percentage of used space for transaction log files (LDF files). You’ll find this useful if your SQL Server has limited capacity, so you need to maximize existing disk space utilization by minimizing unused space. It will also alert you if the percentage of used space exceeds the specified thresholds.

It is best practice to pre-allocate the size of the transaction log file whenever you create a new database. This reduces or eliminates the need for autogrowth, which may lead to physical file fragmentation. The size of the file will depend on the number of transactions you expect, and how often you intend to backup the transaction log.

For information on managing your transaction log, see Understanding Logging and Recovery in SQL Server. For details of how to shrink the size of your transaction log, see Recover from a full transaction log in a SQL Server database.

This metric can be used in conjunction with virtual log file monitoring, particularly if you’re using log reader for replication.

Percentage of used log space, 4.8 out of 5 based on 5 ratings

Metric definition

Metric Name:
Percentage of used log space
Description:
This metric measures the percentage of used space for transaction log files (LDF files).
Enter the T-SQL query that will collect data:
-- create result holder
DECLARE	@result TABLE
	(
	  [Database_Name] VARCHAR(150) ,
	  [Log_Size] FLOAT ,
	  [Log_Space] FLOAT ,
	  [Status] VARCHAR(100)
	) 

INSERT	INTO @result
		EXEC ( 'DBCC sqlperf(LOGSPACE) WITH NO_INFOMSGS'
			)

-- only return for the DB in context, rounding it 
SELECT	ROUND([Log_Space], 2)
FROM	@result
WHERE	[Database_Name] = DB_NAME()
Select instances to collect from:
Select all
Choose databases to collect from:
All databases
Set collection frequency:
Collect data every 5 minutes
Use collected or calculated values:
Leave the Use a calculated rate of change between collections check box turned off
Metric collection is:
Enabled

Alert definition

Alert name:
Free log space decreased
Description:
This alert is raised when the percentage of used space in the log transaction files (LDF) exceeds the specified thresholds.
Raise an alert when the metric value goes:
Above the defined thresholds
Default threshold values:
Set the thresholds as follows:
High:90
Medium:80
Low:Disabled
Raise an alert when the threshold is passed for:
Enter 1 collection
This alert is:
Enabled
VN:F [1.9.17_1161]
Rating: 4.8/5 (5 votes cast)
  • Ulysses

    I have attempted to use this SQL Agent alert several times and it never seems to work properly. I think the issue is due to confusion on exactly what is getting measured and how. The T-SQL query does not return a percentage the query returns the “log space” size as a result The “Metric definition” description (above) states that the “percentage of free space” is measured. The “Alert definition” description (above) indicates that the “amount of free space” is measured. So what type of measure does the threshold values represent?

    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • Hilda

      I believe the metric definition should read as follows: “This alert is raised when the % amount of free space in the log transaction files (LDF) falls above the specified thresholds” and the Raise alert when the metric values goes “Above” and dthe default threshold values should be High: 90, Medium: 80.

      VA:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
    • Priya Sinha

      Thanks for your comment. Apologies, it was mistake on our part. We have corrected this now. It measures percentage of used space.

      VA:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
  • Priya Sinha

    Thanks for your comment. Apologies, it was mistake on our part. We have corrected this now. It measures percentage of used space.

    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)