Learn how to enable logging using both the portal and PowerShell and configured metrics to monitor and log infromation in Azure Storage Accounts.
- [Instructor] Your storage accounts will have to be monitored, just as any other services. You use logs and metrics to monitor the storage account performance, diagnose, and troubleshoot any issues within your accounts. There are a couple of things you need to know about metrics and logging with your storage accounts. First of all, there is a 20-terabyte limit. This is not part of your actual storage account, this is outside your storage account, you're not paying for this. Your logs or metrics will not be deleted, and will continue to be written, until the 20 terabyte is reached.
At that point, nothing else will be written. You can either manually delete your data, or you can set a retention policy. First we have Metrics. Metrics must be enabled for each storage service. They can be used to Analyze the usage of the storage service, Improve the performance of applications, and Diagnose issues related to request to the service. Then we have Transaction Metrics. These metrics include Errors, Availability status, Ingress, and Egress just to name a few.
Metrics can be logged hourly, which include our primary transaction for blobs, tables, and queues. We have our Minutes Metrics, again for our blobs, tables and queues. You'll notice no files in any of those. And then we also have our Capacity metrics. These metrics are only available for the blob service at the time of this recording in January 2017. This metric includes details on the amount of Storage used by the storage account blob service, the Container Count, which is just what it sounds like, the number of containers in the blob service, and the Object Count, which is the number of block or page blobs within the blob service.
In addition to metrics, we also have storage logging, which occurs on the server side. Log files allow you to view the details of the read, write, and delete requests for your tables, queues, and blobs. They contain the start time, and end-to-end latency, including the server latency, success and failure about the operations, the HTTP status code, the Operation type, the Key of the storage job that the client is accessing, the Authentication type that the client is using, the Etag Value, and finally, the Last modified timestamp.
Let's go ahead and take a look at how we enable logging through the portal. I've logged into Azure. I am in my Monitoring and Analytics Resource Group, and you'll notice that I have a couple storage accounts available to me. I have a blob analyticsdemosb storage account, I have a loggingmetricstorage account, and a loggingmetrics2 storage account. I'm going to go ahead and select the Logging Metrics. You will find diagnostics, which is where we set our logging, as you scroll down in our main blade. And you'll go all the way down to Monitoring, and then Diagnostics.
You will notice that this is already set to On. I am going to go ahead and Enable the Blog, Table, and Queue Logs. I can also go ahead and set the Retention Date as required. Be sure to hit Save. Now let's run through a similar procedure on another account using PowerShell. We're actually going to do this on our loggingmetrics2 account. I'm going to go ahead and Open up PowerShell ISE. I've logged into PowerShell ISE in Administrative mode.
I have already logged in to my Azure account, and I have associated the current storage account with my subscription. I can now go ahead and Set the Logging Properties. First, I'm going to go ahead and Enable the Logging Properties for the Queue. To do so, I am going to use the command Set-AzureStorageServiceLoggingProperty. And one of the reasons I like to use ISE, is because the commands as I type, will start populating. It just reduces typos in my world.
Next I have to specify the service account. We already said we are going to do a Queue. Now we have to go ahead and specify our logging operations. And now we can pick and choose which operations we'd like to use. I'm going to go ahead and do All. And then how log do we want to retain these logs in days. And let's say five. I'm going to go ahead and Enter. And let's make sure that this actually worked. To do so, I'm actually going to use the Get-AzureStorageServiceLoggingProperty command. And again, I have to specify my service type.
And there we can see that that has now been enabled with a retention of five days. And now if we pop back into the Azure Portal, watch and see that this has been turned on for that account. I'm already in that storage account. I'm going to click on Diagnostics, and you'll see that the queue logs has been turned on. To recap, setting logs in metrics is incredibly easy to do within your storage account, and you should be reviewing these logs and metrics to ensure that your storage accounts are behaving and performing as you expect.
- Implementing storage blobs and Azure files
- Managing access
- Configuring diagnostics, monitoring, and analytics
- Enabling and viewing logs
- Implementing Azure SQL databases
- Implementing recovery services
- Creating an Azure Backup vault
- Configuring the Azure Backup agent
- Backing up and restoring files
- Backing up an Azure virtual machine