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?
"...", to treat$characters literally (rather than as the start of a variable reference or subexpression to interpolate), you must escape them as`$.$(...)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.