DB File Free Space Left

Microsoft.SQLServer.2016.Monitoring.DBFileSpaceMonitor (UnitMonitor)

The monitor reports a warning when the free space (including both already allocated space and free space on the media) drops below the Warning Threshold setting, expressed as percentage of the sum of data size plus disk free space. The monitor reports a critical alert when the free space drops below the Critical Threshold.

Knowledge Base article:

Summary

The monitor oversees the space available in the file and on the media which hosts the file. The space available on the media is only considered if autogrowth is enabled for the given file.

Causes

An unhealthy state is caused by having low available for this file. Low free space can be caused by:

Use the following link to view the performance data: DB File Free Space Performance Data

No Autogrowth

For a file that has no autogrowth, free space would be the difference between the initial size for a file and the used space.

Autogrowth Enabled

With autogrowth enabled, the available disk space is included as part of the over free space. In addition to the difference between the file size and the used space, the free space for files with autogrowth enabled would be the minimum of either the difference between the max size and the file size and the free space left on disk.

Low free space for database files that have autogrowth could mean that the file is approaching the limits of the hosting logical drive. For files with autogrowth enabled with a max size, low free space could also mean that the file is approaching the max size specified for a file.

The free space calculations also take into account that the file can also fail to grow if the growth amount of the file is greater than the amount left on disk and that the file cannot grow if the difference between the max size and the current file size is less than the growth amount. In these situations, available free space left on disk is not included as part of the free space because we cannot grow any longer.

Resolutions

This issue may be resolved by either:

See SQL Server Books Online: Files and Filegroups Architecture

Overrideable Parameters

Name

Description

Default Value

Alert Priority

Defines Alert Priority.

Normal

Alert Severity

Defines Alert Severity.

Error

Azure Maximum File Size (MB)

The maximum size of data file stored in Azure BLOB Storage. The workflow will consider this value as a maximum storage capacity for each file.

1048576

Critical Threshold

The monitor will change its state to Critical if the value drops below this threshold. Being between this threshold and the warning threshold (inclusive) will result in the monitor being in a warning state.

10

Enabled

Enables or disables the workflow.

Yes

Generates Alerts

Defines whether the workflow generates an Alert.

Yes

Interval (seconds)

The recurring interval of time in seconds in which to run the workflow.

900

Synchronization Time

The synchronization time specified by using a 24-hour format. May be omitted.

 

Timeout (seconds)

Specifies the time the workflow is allowed to run before being closed and marked as failed.

300

Warning Threshold

The monitor will change its state to Warning if the value drops below this threshold.

20

Element properties:

TargetMicrosoft.SQLServer.2016.DBFile
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2016.DBFileSizeMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MSSQL 2016: DB File is running out of space
DB File "{0}" for Filegroup "{1}" in the database "{2}" in SQL instance "{3}" on computer "{4}" is running out of space. See knowledge section for more details.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2016.Monitoring.DBFileSpaceMonitor" Accessibility="Public" Enabled="true" Target="SQL2016Core!Microsoft.SQLServer.2016.DBFile" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2016.DBFileSizeMonitorType" ConfirmDelivery="true">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2016.Monitoring.DBFileSpaceMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.File"]/FileName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.FileGroup"]/GroupName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.Database"]/DatabaseName$</AlertParameter3>
<AlertParameter4>$Target/Host/Host/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.ServerRole"]/InstanceName$</AlertParameter4>
<AlertParameter5>$Target/Host/Host/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter5>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="UnderThreshold1" MonitorTypeStateID="UnderThreshold1" HealthState="Error"/>
<OperationalState ID="OverThreshold1UnderThreshold2" MonitorTypeStateID="OverThreshold1UnderThreshold2" HealthState="Warning"/>
<OperationalState ID="OverThreshold2" MonitorTypeStateID="OverThreshold2" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ConnectionString>$Target/Host/Host/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/ConnectionString$</ConnectionString>
<ServerName>$Target/Host/Host/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ServerName>
<SqlInstanceName>$Target/Host/Host/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.ServerRole"]/InstanceName$</SqlInstanceName>
<ObjectName>SQL DB File</ObjectName>
<CounterName>DB File Free Space (%)</CounterName>
<InstanceName/>
<DatabaseName>$Target/Host/Host/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.Database"]/DatabaseName$</DatabaseName>
<DBFileId>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.File"]/FileID$</DBFileId>
<Value>$Data/Property[@Name='FreeSpacePercent']$</Value>
<Threshold1>10</Threshold1>
<Threshold2>20</Threshold2>
<TimeoutSeconds>300</TimeoutSeconds>
<AzureMaxFileSizeMB>1048576</AzureMaxFileSizeMB>
</Configuration>
</UnitMonitor>