【问题标题】:Monitor per-container size/transaction/bandwidth usage in Azure storage account监控 Azure 存储帐户中每个容器的大小/事务/带宽使用情况
【发布时间】:2021-08-21 22:46:54
【问题描述】:

我有一个应用程序,其中每个用户的杂项文件(主要是图像)都存储在 Azure 存储帐户中的单独 blob 容器中。

文件存储/访问不是应用程序的主要部分(它更像是一个附件),但我想监控每个容器是否存在潜在的过度使用/滥用(存储大小、事务和带宽使用)。

有没有办法使用本机 Azure 工具/API 来实现这一点?我找到的大多数文档都是帐户级别的。

【问题讨论】:

    标签: azure azure-blob-storage azure-monitoring azure-storage-account


    【解决方案1】:

    根据您的场景,目前没有用于容器级别监控的本机工具!通过Azure Storage Explorer可以计算容器、存储帐户和Blob的大小,对于事务、性能可以参考Azure Application Insights(它会自动检测性能异常,并包括强大的分析工具来帮助您诊断问题并了解用户实际上与您的应用有关。它旨在帮助您不断提高性能和可用性。与带宽相关的我们不存储这些信息

    本文使用 Azure Blob 存储清单功能和 Azure Synapse 来计算每个容器的 Blob 计数和总大小。这些值在优化每个容器的 blob 使用时很有用。 Calculate blob count and total size per container using Azure Storage inventory

    $storageAccountName = "xxxx" $StorageAccountKey = "xxxx" #获取上下文
    $ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $StorageAccountKey

    $MaxReturn = 100
    $Token = $Null


    {
    #get 容器
    $storageContainer = Get-AzureStorageContainer -Context $ctx -MaxCount $MaxReturn -ContinuationToken $Token
    $lengthSA = 0

    if($storageContainer.Length -le 0) { Break;}    
    # get a list of all of the blobs in the container    
    foreach($c in $storageContainer)   
        {   
        $cname = $c.Name   
        $length = 0  
        $bMaxReturn = 100    
        $bToken = $Null    
           
        do    
        {    
            # get a list of all of the blobs in the container     
            $listOfBlobs = Get-AzStorageBlob -Container "$cname" -Context $ctx -MaxCount $bMaxReturn  -ContinuationToken $bToken     
            if($listOfBlobs.Length -le 0) { Break;}    
          foreach($blob in $listOfBlobs) {    
            write-host "Blob name:"  
            write-host $blob.Name"("$cname" ) container"  
            write-host "Blob size:"  
            write-host $blob.length"("$cname" ) container"  
            $length = $length + $blob.length  
            }  
            $bToken = $blob[$blob.Count -1].ContinuationToken;  
        }while ($bToken -ne $Null)     
        write-host "The container " $cname " size is $length bytes."  
        $lengthSA = $lengthSA + $length  
        }  
    write-host "The Storage Account "  $storageAccountName " size is $lengthSA bytes."  
    $Token = $c[$c.Count -1].ContinuationToken;    
    

    }while ($Token -ne $Null)

    如果您想对存储日志有​​原生查询体验,建议您使用 Azure 资源日志进行存储。它是新的日志服务,与 Log Analytics 原生集成,您可以在 Portal 中查询日志。

    参考: Monitoring Azure Blob storage | Microsoft Docs Azure Blob storage monitoring data reference | Microsoft Docs

    如果您正在寻找此特定功能,如果您希望可以留下您的反馈here您在这些论坛中分享的所有反馈 将由负责构建 Azure 的 Microsoft 工程团队进行监控和审查。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-08
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多