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

# --- CPU Utilization ---

 template: am_sql_elastic_pool_cpu
       on: azure_monitor.sql_elastic_pool.cpu
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   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 Elastic Pool CPU on ${label:resource_name}
     info: Average CPU utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: dba

 template: am_sql_elastic_pool_instance_cpu
       on: azure_monitor.sql_elastic_pool.instance_cpu
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   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 Elastic Pool instance CPU on ${label:resource_name}
     info: SQL instance CPU utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Includes overhead beyond user workloads
       to: dba

# --- Memory Utilization ---

 template: am_sql_elastic_pool_instance_memory
       on: azure_monitor.sql_elastic_pool.instance_memory
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of average
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (80) : (90))
     crit: $this > (($status == $CRITICAL) ? (90) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool instance memory on ${label:resource_name}
     info: SQL instance memory utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: dba

# --- DTU Utilization ---

 template: am_sql_elastic_pool_dtu_consumption
       on: azure_monitor.sql_elastic_pool.dtu_consumption
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   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 Elastic Pool DTU consumption on ${label:resource_name}
     info: DTU consumption percentage of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           High DTU usage indicates approaching the pool performance limit
       to: dba

# --- I/O Utilization ---

 template: am_sql_elastic_pool_data_io
       on: azure_monitor.sql_elastic_pool.io_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of data_read
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (80) : (90))
     crit: $this > (($status == $CRITICAL) ? (90) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool data I/O on ${label:resource_name}
     info: Physical data read I/O utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: dba

 template: am_sql_elastic_pool_log_write
       on: azure_monitor.sql_elastic_pool.io_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of log_write
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (80) : (90))
     crit: $this > (($status == $CRITICAL) ? (90) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool log write on ${label:resource_name}
     info: Transaction log write utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: dba

# --- Resource Limits ---

 template: am_sql_elastic_pool_workers
       on: azure_monitor.sql_elastic_pool.resource_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of workers
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (70) : (80))
     crit: $this > (($status == $CRITICAL) ? (80) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool workers on ${label:resource_name}
     info: Worker thread utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Exhausting workers causes query failures
       to: dba

 template: am_sql_elastic_pool_sessions
       on: azure_monitor.sql_elastic_pool.resource_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of sessions
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (70) : (80))
     crit: $this > (($status == $CRITICAL) ? (80) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool sessions on ${label:resource_name}
     info: Session utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Exhausting sessions prevents new connections
       to: dba

# --- Storage Utilization ---

 template: am_sql_elastic_pool_storage_used
       on: azure_monitor.sql_elastic_pool.storage_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of used
    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 Elastic Pool storage used on ${label:resource_name}
     info: Data storage utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Reaching the storage limit prevents data inserts and updates
       to: dba

 template: am_sql_elastic_pool_storage_allocated
       on: azure_monitor.sql_elastic_pool.storage_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of allocated
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (80) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool storage allocated on ${label:resource_name}
     info: Allocated data storage utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Allocated space can exceed used space due to database file growth settings
       to: dba

# --- In-Memory OLTP ---

 template: am_sql_elastic_pool_xtp_storage
       on: azure_monitor.sql_elastic_pool.xtp_storage
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of average
    units: percentage
    every: 1m
     warn: $this != nan AND $this > (($status >= $WARNING)  ? (70) : (80))
     crit: $this != nan AND $this > (($status == $CRITICAL) ? (80) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool In-Memory OLTP storage on ${label:resource_name}
     info: In-Memory OLTP storage utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Only relevant when In-Memory OLTP is enabled
       to: dba

# --- Tempdb ---

 template: am_sql_elastic_pool_tempdb_log
       on: azure_monitor.sql_elastic_pool.tempdb_log_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of average
    units: percentage
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (70) : (80))
     crit: $this > (($status == $CRITICAL) ? (80) : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool tempdb log on ${label:resource_name}
     info: Tempdb transaction log utilization of SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           High tempdb log usage can block transactions
       to: dba

# --- Serverless ---

 template: am_sql_elastic_pool_serverless_cpu
       on: azure_monitor.sql_elastic_pool.serverless_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of cpu
    units: percentage
    every: 1m
     warn: $this != nan AND $this > (($status >= $WARNING)  ? (75) : (85))
     crit: $this != nan AND $this > (($status == $CRITICAL) ? (85) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool serverless CPU on ${label:resource_name}
     info: App CPU utilization of serverless SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Only relevant for serverless tier elastic pools
       to: dba

 template: am_sql_elastic_pool_serverless_memory
       on: azure_monitor.sql_elastic_pool.serverless_utilization
    class: Utilization
     type: Database
component: Azure SQL Elastic Pool
   lookup: average -5m unaligned of memory
    units: percentage
    every: 1m
     warn: $this != nan AND $this > (($status >= $WARNING)  ? (80) : (90))
     crit: $this != nan AND $this > (($status == $CRITICAL) ? (90) : (95))
    delay: down 5m multiplier 1.5 max 1h
  summary: SQL Elastic Pool serverless memory on ${label:resource_name}
     info: App memory utilization of serverless SQL Elastic Pool ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Only relevant for serverless tier elastic pools
       to: dba
