Skip to content

Instantly share code, notes, and snippets.

@shawnweisfeld
Created April 21, 2021 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnweisfeld/038d926e462872f72ae88fe896e29ad2 to your computer and use it in GitHub Desktop.
Save shawnweisfeld/038d926e462872f72ae88fe896e29ad2 to your computer and use it in GitHub Desktop.
# Variables
SUB="your azure subscription guid"
RG="the resource group your storage account is in"
STORAGEACCT="the short name of your storage account"
# Resource strings to the account and to the blob service
RESOURCE="/subscriptions/$SUB/resourceGroups/$RG/providers/Microsoft.Storage/storageAccounts/$STORAGEACCT"
BLOBRESOURCE="/subscriptions/$SUB/resourceGroups/$RG/providers/Microsoft.Storage/storageAccounts/$STORAGEACCT/blobServices/default"
# what information can I find out?
az monitor metrics list-definitions --resource $RESOURCE > defn.json
az monitor metrics list-definitions --resource $BLOBRESOURCE > blobdefn.json
# Get me info at the account level
az monitor metrics list --resource $RESOURCE --metric UsedCapacity --interval 1h --offset 1h
# Get me info for just blob storage
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCapacity --interval 1h --offset 1h
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCount --interval 1h --offset 1h
# Get me info for hot blob storage
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCapacity --interval 1h --offset 1h --filter "Tier eq 'Hot'"
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCount --interval 1h --offset 1h --filter "Tier eq 'Hot'"
# Get me info for archive blob storage
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCapacity --interval 1h --offset 1h --filter "Tier eq 'Archive'"
az monitor metrics list --resource $BLOBRESOURCE --metric BlobCount --interval 1h --offset 1h --filter "Tier eq 'Archive'"
# Java examples
# https://github.com/Azure-Samples/monitor-java-query-metrics-activitylogs
# https://github.com/Azure-Samples/monitor-java-query-metrics-activitylogs/blob/2f6c125b7bf586eed9c702de71cd911524a723b2/src/main/java/com/azure/resourcemanager/monitor/samples/QueryMetricsAndActivityLogs.java#L92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment