Loading...

Azure Storage | How to Monitor Azure Storage Account Data | Part -I

Azure Storage | How to Monitor Azure Storage Account Data | Part -I

Storage Analytics logging records details for both successful and failed requests for your storage account. They also enable you to review details of read, write, and delete operations against your Azure tables, queues, and blobs. With Storage logging you can investigate the reasons for failed requests such as timeouts, throttling, latency, and authorization errors.

Further there could be scenarios where you want to know who is writing, reading into their storage account, and which client application has access to the storage account. You may need this information for various business, security, and Audit purposes. This blog series will talk about the same.

 

  • Enable and manage Azure Storage Analytics logs (classic)
  • What is logged vs. what is not logged in Storage Analytics Logs
  • Monitor Access to Storage Activity Logs
  • How to analyse the Storage Analytic logs

 

Enable and manage Azure Storage Analytics logs (classic):

Azure Storage Analytics performs logging and provides metrics data for a storage account. You can use this data to trace requests, analyse usage trends, and diagnose issues with your storage account.

 

Storage Analytics logging records details for both successful and failed requests for your storage account. Storage Analytics logs enable you to review details of read, write, and delete operations against your Azure tables, queues, and blobs. They also enable you to investigate the reasons for failed requests such as timeouts, throttling, latency, and authorization errors.

 

Enable logs:

Storage Analytics logging is not enabled by default for your storage account. You can enable it in the Azure Portal as mentioned in official document or by using PowerShell. For guidance, see below.

 

Enable logs – via PowerShell

You can use PowerShell on your local machine to configure Storage Logging in your storage account by using the Azure PowerShell cmdlet 

Get-AzureStorageServiceLoggingProperty to retrieve the current settings, and the cmdlet Set-AzureStorageServiceLoggingProperty to change the current settings.

Set-AzureStorageServiceLoggingProperty -ServiceType Blob -LoggingOperations    Read,Write,Delete -PassThru -RetentionDays 7 -Version 2.0

For more details, please visit here: https://docs.microsoft.com/en-us/azure/storage/common/manage-storage-analytics

 

Download Storage Analytical Logs:

 Customer can download the log files using a storage explorer or AzCopy

 Download the log files – via Storage explorer

 The easiest way to download the storage analytics logs is using through Storage Explorer.

  Using the below steps, you would be able to download the logs.

  1. Sign-in to azure storage explorer using any of the approaches mentioned here  - https://docs.microsoft.com/en-us/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=wind...
  2. Select the storage of your interest.
  3. Select the $logs container.
  4. Click the “Download” button.

     

rpadi450_0-1650883854023.png

 

For converting the multiple storage analytical logs into a single csv file kindly refer to the below script: -

  .\XLog2CSV.ps1 -inputFolder <input_folder_path> -outputFile <full_path_and_filename_of_csv>

 

 Example:

 

    XLog2CSV.ps1 -inputFolder c:\cases\Logs\2015\08\*.log -outputFile c:\cases\Logs\all_logs.csv

 

 

XLog2CSV.ps1 -inputFolder c:\cases\Logs\2015\08\*.log -outputFile c:\cases\Logs\all_logs.csv

 

 

      Sample output logs.csv:

 

rpadi450_1-1650883854031.png

 

Using AZ Copy:

To work with AZ Copy, you need to generate a SAS token from the portal Azure portal, We need     Read and List permissions to $logs container. Ideally, set duration to about 72 hours so that we will have sufficient time to download the logs.

 

If you use SAS token to authorize access to blob data, then you can append that token to the resource URL in AzCopy command following the below syntax.

 

 

azcopy copy “https://<source-storage-account-name>.blob.core.windows.net/<container-name>/?SAS-token>” “c:\<destination-folder-name” --recursive

 

 

For AZ Copy download, CLI usage and how to use a SAS token, please refer to official documentation

 

What is logged vs. what is not logged in Storage Analytics Logs:

 

Storage Analytics logs detailed information about successful and failed requests to a storage service. This information can be used to monitor individual requests and to diagnose issues with a storage service. Requests are logged on a best-effort basis. This means that most requests will result in a log record, but the completeness and timeliness of Storage Analytics logs are not guaranteed.

 

The following types of authenticated requests and anonymous are logged:

  • Successful requests
  • Failed requests, including timeout, throttling, network, authorization, and other errors
  • Requests using a Shared Access Signature (SAS) or OAuth, including failed and successful requests
  • Requests to analytics data
  • Successful requests
  • Server errors
  • Timeout errors for both client and server
  • Failed GET requests with error code 304 (Not Modified)

The following types of requests are not logged:

  • Requests made by Storage Analytics itself, such as log creation or deletion.
  • Failed anonymous requests are also not logged.

 A full list of the logged data is mentioned here Storage Analytics Logged Operations and Status Messages

 

Monitor Access to Storage Activity Logs:

 

When you have critical applications and business processes that rely on Azure resources, you want to monitor those resources for their availability, performance, and operation. This section describes how you can Monitor Access to the Storage Activity Logs

  1.  Sign in to the Azure portal to get started.
  2. Go to the Monitoring blade and then select the Logs links

               

rpadi450_2-1650883854034.png

 

  1. Click on the default workspace. If the workspace is not available, you will need to create a new Log Analytics workspace by clicking on the +Add button, as mentioned in the link here Create a Log Analytics workspace in the Azure portal - Azure Monitor | Microsoft Docs
  1. In next page, you will see a query window, select your storage account in scope, and click on 'Azure Activity’

                     

rpadi450_3-1650883854036.png

 

  1. Enter your query as mentioned here    

         

rpadi450_4-1650883854038.png

 

  1.  you can also analyse the query results in chat view

 

rpadi450_5-1650883854040.png

 

 

For more details, please visit here: Monitoring Azure Blob Storage | Microsoft Docs

 

How to analyse the Storage Analytic logs:

 

Azure Storage provides analytics logs for Blob, Table, and Queue. The analytics logs are stored as blobs in "$logs" container within the same storage account.

 

The blob name pattern looks like "blob/2018/10/07/0000/000000.log." You can use Azure Storage Explorer to browse the structures and log files. The following screenshot shows the structure in Azure Storage Explorer:

 

rpadi450_6-1650883854044.png

 

 

 

In each log file, each line is one log record for one request divided by semicolon. The following log record shows as a sample of log entry format of version 1.0 and 2.0.

 

 Version 1.0

rpadi450_7-1650883854049.png

 

    Version 2.0

rpadi450_8-1650883854053.png

  For Log entry format versions 1.0 and 2.0 please visit here:

  https://docs.microsoft.com/en-us/rest/api/storageservices/storage-analytics-log-format

  Hope this can be useful!

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Azure Storage - TLS 1.0 and 1.1 retirement

Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...

1 year ago

Efficient Management of Append and Page Blobs Using Azure Storage Actions

  Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...

1 year ago

[Azure AI Search] Internal Server Error when creating CMK encrypted objects

Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...

1 year ago

Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#

Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...

1 year ago

Performing simple Azure Table Storage REST API operations using curl command.

The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...

1 year ago

Bulk delete all the old jobs from the batch account

Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...

1 year ago

Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases

In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...

2 years ago

[Azure Service Bus] JMS messages getting dead-lettered

The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.