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

# ── Streaming Job - Resource Utilization ────────────────────────────────────

 template: am_synapse_streaming_resource_utilization
       on: azure_monitor.synapse.streaming_resource_utilization
    class: Utilization
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of utilization
    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: Synapse streaming SU utilization on ${label:resource_name}
     info: Streaming job resource utilization on Azure Synapse workspace ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           High values indicate the streaming job is approaching capacity
       to: sysadmin

# ── Streaming Job - Errors ──────────────────────────────────────────────────

 template: am_synapse_streaming_runtime_errors
       on: azure_monitor.synapse.streaming_errors
    class: Errors
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of runtime
    units: errors/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (0) : (1))
     crit: $this > (($status == $CRITICAL) ? (1) : (5))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming runtime errors on ${label:resource_name}
     info: Streaming job runtime errors on Azure Synapse workspace ${label:resource_name} \
           in ${label:resource_group} (${label:region})
       to: sysadmin

 template: am_synapse_streaming_data_errors
       on: azure_monitor.synapse.streaming_errors
    class: Errors
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of data_conversion,deserialization
    units: errors/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (0) : (1))
     crit: $this > (($status == $CRITICAL) ? (5) : (10))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming data errors on ${label:resource_name}
     info: Streaming job data conversion and deserialization errors on Azure Synapse workspace \
           ${label:resource_name} in ${label:resource_group} (${label:region})
       to: sysadmin

# ── Streaming Job - Watermark Delay ─────────────────────────────────────────

 template: am_synapse_streaming_watermark_delay
       on: azure_monitor.synapse.streaming_watermark_delay
    class: Latency
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of delay
    units: seconds
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (30) : (60))
     crit: $this > (($status == $CRITICAL) ? (60) : (120))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming watermark delay on ${label:resource_name}
     info: Output watermark delay of the streaming job on Azure Synapse workspace ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           High delay indicates the streaming job is falling behind real-time processing
       to: sysadmin

# ── Streaming Job - Event Timing Issues ─────────────────────────────────────

 template: am_synapse_streaming_late_events
       on: azure_monitor.synapse.streaming_event_timing
    class: Errors
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of late
    units: events/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (5) : (10))
     crit: $this > (($status == $CRITICAL) ? (25) : (50))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming late events on ${label:resource_name}
     info: Rate of late-arriving input events in the streaming job on Azure Synapse workspace \
           ${label:resource_name} in ${label:resource_group} (${label:region})
       to: sysadmin

 template: am_synapse_streaming_out_of_order_events
       on: azure_monitor.synapse.streaming_event_timing
    class: Errors
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of out_of_order
    units: events/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (5) : (10))
     crit: $this > (($status == $CRITICAL) ? (25) : (50))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming out-of-order events on ${label:resource_name}
     info: Rate of out-of-order input events in the streaming job on Azure Synapse workspace \
           ${label:resource_name} in ${label:resource_group} (${label:region})
       to: sysadmin

 template: am_synapse_streaming_backlogged_events
       on: azure_monitor.synapse.streaming_event_timing
    class: Workload
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of backlogged
    units: events/s
    every: 1m
     warn: $this > (($status >= $WARNING)  ? (50) : (100))
     crit: $this > (($status == $CRITICAL) ? (100) : (500))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse streaming backlogged events on ${label:resource_name}
     info: Rate of backlogged input event sources in the streaming job on Azure Synapse workspace \
           ${label:resource_name} in ${label:resource_group} (${label:region}). \
           Backlog growth indicates input rate exceeds processing capacity
       to: sysadmin

# ── Integration - Link Processing Latency ───────────────────────────────────

 template: am_synapse_link_processing_latency
       on: azure_monitor.synapse.link_processing_latency
    class: Latency
     type: Database
component: Azure Synapse
   lookup: average -5m unaligned of average
    units: seconds
    every: 1m
     warn: $this != nan AND $this > (($status >= $WARNING)  ? (30) : (60))
     crit: $this != nan AND $this > (($status == $CRITICAL) ? (60) : (120))
    delay: down 5m multiplier 1.5 max 1h
  summary: Synapse Link processing latency on ${label:resource_name}
     info: Average Synapse Link processing latency on Azure Synapse workspace ${label:resource_name} \
           in ${label:resource_group} (${label:region}). \
           Only relevant when Synapse Link connections are configured
       to: sysadmin
