azure-xplat-cli icon indicating copy to clipboard operation
azure-xplat-cli copied to clipboard

Insights Metrics

Open gatneil opened this issue 8 years ago • 2 comments

version: 0.10.6 (node: 4.2.6) installation: npm

From the output below, it seems the CLI only supports getting metrics for web, sql, and documentdb. It doesn't even let me get metrics for VMs. This is more of a feature request than a bug, but it would be very helpful to be able to get metrics from the CLI...

negat@jumpbox:~$ azure insights metrics list MY_RESORCE_ID MY_TIME_GRAIN info: Executing command insights metrics list info: Cli can retrieve metrics for microsoft.web, microsoft.sql, and microsoft.documentdb. PowerShell can retrieve for any resource type.

gatneil avatar Oct 25 '16 00:10 gatneil

@gucalder - Can you please take a look at this issue?

amarzavery avatar Nov 04 '16 16:11 amarzavery

Actually, both metrics and metrics definitions seem to be broken. They changed the API fairly recently, and the URL required to get that information has changed. In addition, the CLI seems to be using an invalid api-version, probably because the provider information for metrics being returned by Azure is bogus.

I tried this command:

azure insights metrics definition list "/subscriptions/xxx/resourceGroups/dberger1/providers/Microsoft.Compute/virtualMachines/dberger1"

And it generated the following URL:

'https://management.azure.com//subscriptions/xxx/resourceGroups/dberger1/providers/Microsoft.Compute/virtualMachines/dberger1/metricDefinitions?api-version=2015-07-01&$filter='

When it should generate this:

'https://management.azure.com/subscriptions/xxx/resourceGroups/dberger1/providers/Microsoft.Compute/virtualMachines/dberger1/providers/microsoft.insights/metricdefinitions?api-version=2016-03-01'

According to the documentation (https://msdn.microsoft.com/library/dn931930.aspx) the api-version should be 2016-03-01 for metrics definitions, and 2016-09-01 for metrics. With those api-version strings in place I have been able to make them work for our own library.

The URL you're generating requires the older api-version string of 2014-04-01.

The odd thing is that not only is the format of the resulting output different than the older version, I also seem to get far fewer metrics definitions with the newer API. I'm not sure why that is yet, but I'm looking into it.

(Update: I guess that's just how the newer API works: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics)

Anyway, fixing the api-version and generated URL should fix the issue.

djberg96 avatar Jan 05 '17 14:01 djberg96