我正在尝试获取 Microsoft.Sql/servers/ 资源的指标:resource_id 是:/subscriptions/******-8**2-44**-95**-****13a5****/resourceGroups/SQLTesting/providers/Microsoft.Sql/servers/sqltest
如示例指标
resource_id="/subscriptions/******-8**2-44**-95**-****13a5****/resourceGroups/SQLTesting/providers/Microsoft.Sql/servers/sqltest"
today = datetime.datetime.now().date()
yesterday = today - datetime.timedelta(days=1)
metrics_data = client.metrics.list(
resource_id,
timespan="{}/{}".format(yesterday, today),
interval='PT1H',
metricnames='dtu_used',
aggregation='Average'
)
for item in metrics_data.value:
# azure.mgmt.monitor.models.Metric
print("{} ({})".format(item.name.localized_value, item.unit.name))
for timeserie in item.timeseries:
for data in timeserie.data:
# azure.mgmt.monitor.models.MetricData
print("{}: {}".format(data.time_stamp, data.total))
但我收到ErrorResponseException: Metric: dtu_used does not accept zero dimension case错误。如何解决?