Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Recovery Services Vault notification preferences #5423

Open
elliot-resdiary opened this issue Jan 16, 2020 · 7 comments
Open

Support for Recovery Services Vault notification preferences #5423

elliot-resdiary opened this issue Jan 16, 2020 · 7 comments

Comments

@elliot-resdiary
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

It's great that we have the resources to create Recovery Services Vaults, protection policies, and VM protection, however, arguably just as important as the backups themselves are the email notification preferences which let us know when backups aren't running or have been deleted.

New or Affected Resource(s)

  • azurerm_recovery_services_vault

Potential Terraform Configuration

resource "azurerm_recovery_services_vault" "rsv" {
  name                = "example-rsv"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "Standard"

  notifications = {
      email_subscription_owner = true
      custom_emails = [
          "admin1@example.com",
          "admin2@example.com"
      ]
  }
}

References

@sean-nixon
Copy link
Contributor

I'd also be interested in this feature, but support for it might be tricky. Based on configuring this in the Portal, the endpoint for backup notifications appears to be the following:

PATCH https://management.azure.com/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.RecoveryServices/vaults/xxx/monitoringConfigurations/notificationConfiguration?api-version=2017-07-01-preview

However, I'm unable to find any documentation on this endpoint in the API reference docs and no equivalent client in the azure-sdk-for-go.

@elliot-resdiary
Copy link
Author

@sean-nixon
Copy link
Contributor

That's specific for Azure Site Recovery replication alerts and doesn't cover backup. Configuring that is equivalent to setting "Email notifications" on "Site Recovery events" in the Portal.

image

Backup notifications are set in the Portal at "Backup Alerts" > "Configure notifications" and use the seemingly undocumented endpoint I described above if you look in the browser network calls.

image

Your initial issue sounded like you were wanting backup notifications specifically. Regardless, I would love it if Terraform supported both types. Building off your example, a potential configuration could be:

resource "azurerm_recovery_services_vault" "rsv" {
  name                = "example-rsv"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku                 = "Standard"

  replication_notifications = {
      email_subscription_owner = true
      custom_emails = [
          "admin1@example.com",
          "admin2@example.com"
      ]
      locale = "en-US"
  }
 
  backup_notifications = {
      recipient_emails = [
          "admin2@example.com"
       ]
     severities = [
         "Critical",
         "Warning",
         "Information"
     ]
     frequency = "Hourly" # or "Immediate"
  }
}

@hj2m

This comment has been minimized.

@nitmatgeo

This comment has been minimized.

@SteveKurutz
Copy link

I agree that adding support for backup alerting settings is necessary. Due to the relationships between vaults, regions, and subscriptions, it's necessary to deploy multiple vaults to back up "one" organization. This results in a whole lot of manual configuration on a vault-by-vault basis.

Similarly, enabling the setting of diagnostic logging in TF would be helpful. As it stands, we can only automate 80% of what's important to us about vault configuration due to these limitations.

@Klaas-
Copy link
Contributor

Klaas- commented May 5, 2022

So my understanding is that the metrics alert is the way to go forward here, you can add them with tf already, a backup alert for failing backups should look something like this:

resource "azurerm_monitor_metric_alert" "backup_health" {
  name                     = "backup health alert"
  resource_group_name      = azurerm_resource_group.resource_group.name
  scopes                   = [azurerm_recovery_services_vault.backup_vault.id]
  description              = "Alert on Backup Health Events"
  target_resource_type     = "Microsoft.RecoveryServices/vaults"
  auto_mitigate            = true
  frequency                = "PT1H"
  window_size              = "P1D"

  criteria {
    metric_namespace = "Microsoft.RecoveryServices/vaults"
    metric_name      = "BackupHealthEvent"
    aggregation      = "Count"
    operator         = "GreaterThan"
    threshold        = "0"

    dimension {
      name     = "dataSourceURL"
      operator = "Include"
      values   = [
        "*"
      ]
    }

    dimension {
      name     = "healthStatus"
      operator = "Exclude"
      values   = ["Healthy"]
    } 
  }
  action {
    action_group_id    = ...
    webhook_properties = {}
  }  
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants