# you can disable an alarm notification by setting the 'to' line to: silent

# --- Utilization ---

 template: am_sql_managed_instance_cpu
       on: azure_monitor.sql_managed_instance.cpu
    class: Utilization
     type: Database
component: Azure SQL MI
   lookup: average -5m unaligned of average
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (75) : (85))
     crit: $this > (($status == $CRITICAL) ? (85) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL MI CPU utilization on ${label:resource_name}
     info: Average CPU utilization of SQL Managed Instance ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Sustained high CPU indicates insufficient compute tier or query optimization needed
       to: dba

 template: am_sql_managed_instance_storage_utilization
       on: azure_monitor.sql_managed_instance.storage
    class: Utilization
     type: Database
component: Azure SQL MI
     calc: ($reserved > 0) ? ($used * 100 / $reserved) : (0)
    units: %
    every: 5m
     warn: $this > (($status >= $WARNING)  ? (80) : (85))
     crit: $this > (($status == $CRITICAL) ? (85) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL MI storage utilization on ${label:resource_name}
     info: Storage used as a percentage of reserved storage on SQL Managed Instance ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Approaching reserved storage limit may cause write failures
       to: dba

# --- Workload ---

 template: am_sql_managed_instance_io_requests
       on: azure_monitor.sql_managed_instance.io_requests
    class: Workload
     type: Database
component: Azure SQL MI
   lookup: average -5m unaligned of average
    units: requests/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (4000) : (5000))
     crit: $this > (($status == $CRITICAL) ? (5000) : (7500))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL MI I/O requests on ${label:resource_name}
     info: Average I/O requests per second on SQL Managed Instance ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           High I/O request rates may indicate I/O bottleneck or unoptimized queries
       to: dba
