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

# helper: total pull rate over 5 minutes (used as denominator for failure ratio)

 template: am_container_registry_pull_total
       on: azure_monitor.container_registry.pull_count
    class: Workload
     type: Containers
component: Azure ACR
   lookup: average -5m unaligned of total
    units: pulls/s
    every: 1m
     info: Total image pull rate on ACR ${label:resource_name}

# Pull failure ratio: fires only when there is meaningful pull traffic

 template: am_container_registry_pull_failures
       on: azure_monitor.container_registry.pull_count
    class: Errors
     type: Containers
component: Azure ACR
   lookup: average -5m unaligned of successful
     calc: ($am_container_registry_pull_total > 0.01) ? (($am_container_registry_pull_total - $this) * 100 / $am_container_registry_pull_total) : (0)
    units: %
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (1) : (5))
     crit: $this > (($status == $CRITICAL) ? (5) : (15))
    delay: down 5m multiplier 1.5 max 1h
  summary: ACR pull failures on ${label:resource_name}
     info: Percentage of failed image pulls on ACR ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: sysadmin

# helper: total push rate over 5 minutes (used as denominator for failure ratio)

 template: am_container_registry_push_total
       on: azure_monitor.container_registry.push_count
    class: Workload
     type: Containers
component: Azure ACR
   lookup: average -5m unaligned of total
    units: pushes/s
    every: 1m
     info: Total image push rate on ACR ${label:resource_name}

# Push failure ratio: fires only when there is meaningful push traffic

 template: am_container_registry_push_failures
       on: azure_monitor.container_registry.push_count
    class: Errors
     type: Containers
component: Azure ACR
   lookup: average -5m unaligned of successful
     calc: ($am_container_registry_push_total > 0.01) ? (($am_container_registry_push_total - $this) * 100 / $am_container_registry_push_total) : (0)
    units: %
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (1) : (5))
     crit: $this > (($status == $CRITICAL) ? (5) : (15))
    delay: down 5m multiplier 1.5 max 1h
  summary: ACR push failures on ${label:resource_name}
     info: Percentage of failed image pushes on ACR ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: sysadmin
