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

# --- Availability ---

# Storage account availability (0-100%). Low is bad.
# Azure SLA guarantees >=99.9% for RA-GRS/RA-GZRS, >=99.9% for most tiers.
# AMBA: Availability < 99% is Sev1 (critical)

 template: am_storage_accounts_availability
       on: azure_monitor.storage_accounts.availability
    class: Availability
     type: Storage
component: Azure Storage
   lookup: average -5m unaligned of average
    units: percentage
    every: 1m
     warn: $this < (($status >= $WARNING)  ? (99.9) : (99))
     crit: $this < (($status == $CRITICAL) ? (99)   : (90))
    delay: down 5m multiplier 1.5 max 1h
  summary: Storage availability on ${label:resource_name}
     info: Overall availability of Azure Storage Account ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Azure SLA guarantees 99.9% or higher depending on redundancy tier
       to: sysadmin

# --- Latency ---

# End-to-end latency measures the full round-trip including network.
# AMBA: SuccessE2ELatency average > 1000ms is Sev2

 template: am_storage_accounts_e2e_latency
       on: azure_monitor.storage_accounts.e2e_latency
    class: Latency
     type: Storage
component: Azure Storage
   lookup: average -5m unaligned of average
    units: milliseconds
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (500)  : (1000))
     crit: $this > (($status == $CRITICAL) ? (1000) : (2000))
    delay: down 5m multiplier 1.5 max 1h
  summary: Storage E2E latency on ${label:resource_name}
     info: Average end-to-end latency of successful requests to Azure Storage Account \
           ${label:resource_name} in ${label:resource_group} (${label:region}). \
           Includes network round-trip time
       to: sysadmin

# Peak end-to-end latency — catches extreme spikes even when average looks normal.

 template: am_storage_accounts_e2e_latency_peak
       on: azure_monitor.storage_accounts.e2e_latency
    class: Latency
     type: Storage
component: Azure Storage
   lookup: max -5m unaligned of maximum
    units: milliseconds
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (2000) : (5000))
     crit: $this > (($status == $CRITICAL) ? (5000) : (10000))
    delay: down 5m multiplier 1.5 max 1h
  summary: Storage E2E latency peak on ${label:resource_name}
     info: Peak end-to-end latency of successful requests to Azure Storage Account \
           ${label:resource_name} in ${label:resource_group} (${label:region}). \
           Spikes may indicate throttling or network congestion
       to: sysadmin

# Server-side latency excludes network — pure Azure processing time.
# AMBA: SuccessServerLatency average > 1000ms is Sev2

 template: am_storage_accounts_server_latency
       on: azure_monitor.storage_accounts.server_latency
    class: Latency
     type: Storage
component: Azure Storage
   lookup: average -5m unaligned of average
    units: milliseconds
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (300) : (500))
     crit: $this > (($status == $CRITICAL) ? (500) : (1000))
    delay: down 5m multiplier 1.5 max 1h
  summary: Storage server latency on ${label:resource_name}
     info: Average server-side latency of successful requests to Azure Storage Account \
           ${label:resource_name} in ${label:resource_group} (${label:region}). \
           Excludes network time — high values indicate Azure-side processing delays
       to: sysadmin

# Peak server-side latency — catches extreme server-side spikes.

 template: am_storage_accounts_server_latency_peak
       on: azure_monitor.storage_accounts.server_latency
    class: Latency
     type: Storage
component: Azure Storage
   lookup: max -5m unaligned of maximum
    units: milliseconds
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (1000) : (2000))
     crit: $this > (($status == $CRITICAL) ? (2000) : (5000))
    delay: down 5m multiplier 1.5 max 1h
  summary: Storage server latency peak on ${label:resource_name}
     info: Peak server-side latency of successful requests to Azure Storage Account \
           ${label:resource_name} in ${label:resource_group} (${label:region}). \
           Spikes may indicate throttling at the storage partition level
       to: sysadmin
