balajij8
Contributor III

You can follow the same approach of using swapping out the subscriptions (alert subscriptions) based on the target for the alerts. You can follow below & change the alert subscriptions based on targets

Target Prod
     alert_subscriptions:
        - user_email: 'rvm@mosr.com'
        - pager_destination_id: 'a18db8fa-36ed-46d9-a085-6c3517daf232'​​

Target Rest
    alert_subscriptions:
        - user_email: 'rvm@mosr.com'​

You can setup the alert as below. It stays completely target agnostic as it references the alert_subscriptions setup earlier

resources:
  alerts:
    aalerts:
      display_name: aalerts
      evaluation:
        comparison_operator: EQUAL
        source:
          name: '1'
        threshold:
          value:
            double_value: 2
        notification:
          notify_on_ok: false
          subscriptions: ${var.alert_subscriptions}
      query_text: select 2
      schedule:
        quartz_cron_schedule: '44 19 */1 * * ?'
        timezone_id: Europe/Amsterdam
      warehouse_id: 460a05ed

You can use below to find UUID

w = WorkspaceClient()
destinations = w.notification_destinations.list()

for dest in destinations:
    print(dest)

Ensure the alert file containing alerts details is included under include in the yml. Ensure the UUID is sent for the pager duty as above to avoid the error "Expected UUID, found"

View solution in original post