0

I am following https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-compute-virtualmachines-metrics to export some metrics from Azure.

If build some code that works just fine, I can retrieve all the metrics as in the docs. The relevant code for this is:

 $uri = "https://management.azure.com/subscriptions/$($subscription)/resourceGroups/$($resourceGroup)/providers/Microsoft.Compute/virtualMachines/$($vmname)/providers/microsoft.insights/metrics?api-version=2024-02-01&metricnames=$($metricName)&interval=PT5M"
 $data = Invoke-RestMethod -Method GET -Uri $uri -Headers $header 

However I need to split the Data Disk Queue Depth per LUN. The doc states that this is available as a dimension. It also states, "Dimensions - Dimensions available for the metric." (super helpful). The link on dimensions (https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/metrics-aggregation-explained#dimensions-splitting-and-filtering) is only explain what dimensions are, not how to filter/split them by API call.

How can I split/filter per dimension in my API call?

2
  • In short: Inside "...", to treat $ characters literally (rather than as the start of a variable reference or subexpression to interpolate), you must escape them as `$. Commented Jul 11 at 17:53
  • As an aside: you don't strictly need $(...) in order to embed simple variable references inside "...". If you must disambiguate the name, enclose it in { and }, e.g. ${vmname}. For an overview of all string-interpolation rules, see this answer. Commented Jul 11 at 17:57

1 Answer 1

0

So I was close. I tested with $filter=LUN eq '*' before without any result

 $uri = "https://management.azure.com/subscriptions/$($subscription)/resourceGroups/$($resourceGroup)/providers/Microsoft.Compute/virtualMachines/$($vmname)/providers/microsoft.insights/metrics?api-version=2024-02-01&metricnames=$($metricName)&interval=PT5M$filter=LUN eq '*'"

The tweak is to escape the $ in $filter

 $uri = "https://management.azure.com/subscriptions/$($subscription)/resourceGroups/$($resourceGroup)/providers/Microsoft.Compute/virtualMachines/$($vmname)/providers/microsoft.insights/metrics?api-version=2024-02-01&metricnames=$($metricName)&interval=PT5M`$filter=LUN eq '*'"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.