Reputation: 66637
// get metric definitions for storage account.
for (MetricDefinition metricDefinition : azure.metricDefinitions().listByResource(storageAccount.id())) {
Azure github has this example to get metrics for a storage account. I am struggling to find any reference on what should be passed as parameter to listByResource()
to get VM Metric (for example Network In metric)? Appreciate any input.
Upvotes: 0
Views: 417
Reputation: 14324
Firstly, if you want to get metrics supported by Azure Monitor, you could use this to query records. You could also find it in the sample code.
MetricCollection metricCollection = metricDefinition.defineQuery()
.startingFrom(recordDateTime.minusDays(7))
.endsBefore(recordDateTime)
.withAggregation("Average")
.withInterval(Period.minutes(5))
.withOdataFilter("apiName eq 'PutBlob' and responseType eq 'Success' and geoType eq 'Primary'")
.execute();
And about the method description, you could refer to this site.
As for the VM NetWork metric, I suppose it's not supported, in the official doc :Supported metrics with Azure Monitor on Azure Stack, it lists metrics supported by Azure Monitor. With Microsoft.Compute/virtualMachines, it only supports the Percentage CPU metric.
Upvotes: 1