Monitoring Storage Replication - Part 2
Published Mar 07 2023 11:00 PM 2,545 Views
Microsoft

Introduction

Hi folks! My name is Felipe Binotto, Cloud Solution Architect, based in Australia.

 

This is part 2 of Monitoring Storage Replication, if you missed part 1 you can find it HERE.

 

In part 1, we configured an Automation Runbook to collect replication data for Storage Accounts and stored it in a custom table in a Log Analytics workspace.

 

In this post, I will demonstrate how you can leverage that data stored in Log Analytics to generate Azure Alerts which trigger a Logic App and send a customized email to the owner of the Storage Account which is defined as a tag value of the Storage Account.

 

Pre-Requisites

Before we begin, please ensure that you have the following prerequisites in place:

 

  • Azure Subscription
  • Automation Account
  • Log Analytics workspace
  • Logic App

 

High-Level Steps

The process of notifying the owner of the storage account can be broken down in a couple of steps, which we will go through in the following order:

 

  1. Create and configure an Azure Alert.
  2. Configure the Logic App.

 

Getting Started

From the Azure Portal, navigate to your Log Analytics workspace where you have the custom table with the Storage Account replication data, click on Alerts, click on Create and select Alert Rule.

 

fbinotto_0-1678238447859.png

 

 

From the Select a signal page, select Custom log search.

 

fbinotto_1-1678238447862.png

 

 

Next paste the following query in the Search query box.

 

 

StorageReplicationHealth_CL
| where TimeGenerated >= ago(23h)
| where todatetime(Storage_LastSyncTime_s) < ago(24h)

 

 

This means we want all the events that were generated in the last 23 hours and from those events only storage accounts that have not synchronized in the last day. Adapt it to your requirements.

 

For the aggregation granularity select 1 day.

 

For dimensions, I am selecting Storage_Name_s, Storage_LastSyncTime_s and Owner_s, but you could select other dimensions if you are collecting them. Also note that in Dimension values you may not have anything if you do not have any Storage Accounts which match the query parameters.

 

Finally, on Threshold value select 1 which means if the query returns more than 1 result the alert should be triggered.

 

 

fbinotto_2-1678238447866.png

 

 

Now, on Actions, select Create action group.

 

fbinotto_3-1678238447867.png

 

On the Basics tab, provide the basic details and skip to the Actions tab. On the Actions tab, as the Action type choose Logic App, give it a name, and select the Logic App you have created previously.

 

Create the Action group.

 

fbinotto_4-1678238447870.png

 

Note: you must have a “When a HTTP request is received” configured in your Logic App. Otherwise, you will not be able to select it in the previous step.

 

fbinotto_5-1678238447871.png

 

Once that is done. The only remaining step on the alert rule is to configure the Details tab and click to create it.

Now it is time to configure the Logic App. First step is to Initialize some variable which will be used during the workflow. If you have added extra dimensions in the previous steps, make sure you initialize variables for those too.

 

All variables should be of type string and no value is required.

 

fbinotto_6-1678238447872.png

 

 

In this next step, you may have to zoom in a bit because there is a lot going on. Here are the steps:

 

  1. Create a Foreach and select allOf as the output from previous steps.
  2. Create a nested Foreach and select dimensions.
  3. Create a Switch inside the second Foreach and select name.
  4. Create one case for each of the variables, in the picture below is an example of creating the first case where it equals to Owner_s.
  5. Inside the case, create a Set variable, with name Owner and Value value.
  6. Repeat the previous step for each variable you want to set based on your dimensions.

 

 

fbinotto_7-1678238447874.png

 

The last two steps are to compose the email and send it out.

 

fbinotto_8-1678238447875.png

 

For the compose, I recommend you use an example from Sandro Pereira, which you can get it from HERE.

Copy and paste the content in your Compose. Then you can adapt the HTML (Hyper Text Markup Language) code and include the variables you want like shown below.

 

fbinotto_9-1678238447876.png

 

The last step is to create a Send an email (V2) and connect with your M365 account. Once that is done, select Outputs for the Body of the email and the Owner variable for the To field.

 

fbinotto_10-1678238447878.png

 

 

Conclusion

In conclusion, monitoring the replication of your Azure Storage Account is crucial to ensure that your data is always available and secure. By configuring alerts and setting up a Logic App to send email notifications, you can stay on top of any potential issues and act before they cause significant problems.

 

Through this article and part 1, we have discussed step-by-step instructions on how to set up monitoring and alerting for Azure Storage Account replication using Azure Monitor and Logic Apps. This approach provides a reliable and straightforward way to receive notifications whenever replication issues arise, giving you the chance to investigate and fix the problem promptly.

 

With this process in place, you can have peace of mind knowing that your data is continuously replicated and available, even in the event of an outage or other issues. We hope this article has been helpful in guiding you through the process of monitoring Azure Storage Account replication and implementing an effective alerting system to keep you informed of any potential problems.

 

Thanks for reading!

 

 

Disclaimer

The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

 

Co-Authors
Version history
Last update:
‎Mar 07 2023 05:34 PM
Updated by: