azureazure-sql-databaseazure-sql-managed-instanceazure-alertssql-azure-alerts

How to Setup Alert on Azure SQL MI instance for % storage space used?


We need to setup Alert if 80% of space used by Azure SQL MI instance then it should be alerted. In existing Alert metrics not provide option to use value in percentage(%). So anyone have any idea how we can setup alert on % space used by azure mi?


Solution

  • If you have defined diagnostic settings such that the SQLMI sends its metrics to a log analytics workspace, you can use a log search alert:

    AzureMetrics
    | extend p = pack(MetricName, Average)
    | summarize bag = make_bag(p) by TimeGenerated
    | evaluate bag_unpack(bag)
    | extend reserved_storage = reserved_storage_mb
    | extend used_storage = storage_space_used_mb
    | extend storage_used_percentage = round(100.0 * used_storage / reserved_storage)
    | project TimeGenerated, storage_used_percentage, reserved_storage, used_storage
    | where storage_used_percentage >= 80