Enabling and Configuring Storage Analytics

Storage Analytics metrics are enabled by default for new storage accounts. You can enable logging and configure both metrics and logging in the Azure portal; for details, see Monitor a storage account in the Azure portal. You can also enable Storage Analytics programmatically via the REST API or the client library. Use the Set Service Properties operation for an individual service to enable Storage Analytics.

Note

Storage Analytics metrics are available for the Blob, Queue, Table, and File services.

Storage Analytics logging is available for the Blob, Queue, and Table services.

The following example enables Storage Analytics for the Table service of a fictional account named myaccount.

Important

Although hourly metrics are enabled by default for new storage accounts, minute metrics must be enabled programmatically. You can also use PowerShell and the Azure CLI 2.0 to enable minute metrics.

  1. Configure your request URI and headers to match the following examples. The HTTP method is PUT, and you must apply an authentication scheme to sign the request. For more information about signing your request, see Authentication for the Azure Storage Services.

    PUT https://myaccount.table.core.windows.net/?restype=service&comp=properties HTTP/1.1  
    x-ms-version: 2013-08-15  
    x-ms-date: Wed, 23 Oct 2013 04:28:19 GMT  
    Authorization: SharedKey  
    myaccount:Z1lTLDwtq5o1UYQluucdsXk6/iB7YxEu0m6VofAEkUE=  
    Host: myaccount.table.core.windows.net  
    
  2. Your request also needs a request body, consisting of XML that the storage service will process and use to configure Storage Analytics. The following example enables logging for delete and write requests and sets a log retention policy of 7 days. It also enables hourly and minute metrics, excludes API-level summary statistics, and sets a metrics data retention policy of 7 days.

    <?xml version="1.0" encoding="utf-8"?>  
    <StorageServiceProperties>  
        <Logging>  
            <Version>1.0</Version>  
                  <Delete>true</Delete>  
            <Read>false</Read>  
            <Write>true</Write>  
            <RetentionPolicy>  
                <Enabled>true</Enabled>  
                <Days>7</Days>  
            </RetentionPolicy>  
        </Logging>  
        <HourMetrics>  
            <Version>1.0</Version>  
            <Enabled>true</Enabled>  
            <IncludeAPIs>false</IncludeAPIs>  
            <RetentionPolicy>  
                <Enabled>true</Enabled>  
                <Days>7</Days>  
            </RetentionPolicy>  
        </HourMetrics>  
        <MinuteMetrics>  
            <Version>1.0</Version>  
            <Enabled>true</Enabled>  
            <IncludeAPIs>false</IncludeAPIs>  
            <RetentionPolicy>  
                <Enabled>true</Enabled>  
                <Days>7</Days>  
            </RetentionPolicy>  
        </MinuteMetrics>  
    ...
    </StorageServiceProperties>  
    
  3. When this request is sent, it will receive a response that will indicate whether or not Storage Analytics was configured. If the response has an HTTP status code of 202 (Accepted), your Storage Analytics settings have been updated. The following example response indicates that our settings were updated:

    HTTP/1.1 202 Accepted  
    Connection: Keep-Alive  
    Transfer-Encoding: chunked  
    Date: Wed, 23 Oct 2013 04:28:20 GMT  
    Server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0  
    x-ms-request-id: cb939a31-0cc6-49bb-9fe5-3327691f2a30  
    x-ms-version: 2013-08-15  
    

    After you have enabled Storage Analytics with your initial configuration, you can always get your current settings by calling the Get Blob Service Properties, Get Table Service Properties, or Get Queue Service Properties operation.

Updating Storage Analytics

To change Storage Analytics settings for a storage service, call the Set Service Properties operation again. Ensure that your new XML request body retains your desired configuration options, such as enabling/disabling Storage Analytics and/or a retention policy for the service. Each time one of these operations is called, it changes the applicable service’s settings immediately.

See Also

Setting a Storage Analytics Data Retention Policy
Set Blob Service Properties
Get Blob Service Properties
Set Table Service Properties
Get Table Service Properties
Set Queue Service Properties
Get Queue Service Properties
Set File Service Properties
Get File Service Properties