0
votes

I would like to set up an Azure alert for when someone on our team sets up an Azure database. Once alerted, I want to have an additional alert created if that resource is running for more than a certain amount of time.

My solution is to create an Alert Rule on the storage account and have it send an email. Where I'm running into trouble is how to monitor the database, since it just got created and I don't know the name yet for the second Alert rule that will monitor its uptime.

Is there some programmatic way to determine the database resource name?

2

2 Answers

1
votes

If you don't want to invest time in Programmatic way there is a option to set or configure an alert at Resource Group level based on Resource type, where in the alert rule configure with below configurations

  1. Scope -Select the right subscription, filter by resource type like SqlDatabase and if required filter based on location wise
  2. Condition - In Select condition, Signal type drop down select "Create/Update Azure Sql Database" and in alert logic you can provide additional filtering logic's
  3. Can choose existing Action group or create new one based on your requirement
  4. Add "Alert rule details" like rule name, description etc.
  5. Finally create alert rule

Now once alert rule is created if any new Azure SqlDatabase is created you will be notified based on alert configured.

0
votes

According to the official doc, you can use Event Grid to notify Azure Automation when a SQL database is created.

https://docs.microsoft.com/en-au/azure/event-grid/overview#ops-automation

Once you subscribe, you can use Logic Apps to send you an email for example.

About the second part, you'll need to query the metrics and figure out if it's running (is performing compute) or not.