如果您在使用APIM服务时遇到了"APIM服务未检索到指标"的问题,以下是一些可能的解决方法。
az resource update --ids /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.ApiManagement/service/{APIMServiceName}/providers/microsoft.insights/metrics/indexes/ApiManagement
请将{SubscriptionId}
替换为您的订阅ID,{ResourceGroupName}
替换为APIM服务所在的资源组名称,以及{APIMServiceName}
替换为APIM服务的名称。
az monitor metrics list --resource /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.ApiManagement/service/{APIMServiceName} --resource-type Microsoft.ApiManagement/service --metric-names TotalRequests, FailedRequests
请将{SubscriptionId}
替换为您的订阅ID,{ResourceGroupName}
替换为APIM服务所在的资源组名称,以及{APIMServiceName}
替换为APIM服务的名称。
确保您具有足够的权限来检索APIM服务的指标。您可以检查是否具有适当的权限,以及是否为当前用户分配了APIM服务的角色。
如果您使用的是自定义域名,请确保将自定义域名与APIM服务正确关联。您可以通过以下代码示例来关联自定义域名:
az apim update --name {APIMServiceName} --resource-group {ResourceGroupName} --hostname-configurations [{name=custom-domain, type=Proxy, hostName={CustomDomainName}}]
请将{APIMServiceName}
替换为APIM服务的名称,{ResourceGroupName}
替换为APIM服务所在的资源组名称,以及{CustomDomainName}
替换为您的自定义域名。
az apim show --name {APIMServiceName} --resource-group {ResourceGroupName} --query 'sku.name'
请将{APIMServiceName}
替换为APIM服务的名称,{ResourceGroupName}
替换为APIM服务所在的资源组名称。
如果您仍然遇到问题,建议您查看官方文档或联系Microsoft支持获取更详细的帮助和支持。