使用REST API或Java SDK检索VM CPU百分比度量 [英] VM CPU Percent Metric retrieval using REST API or Java SDK

查看:73
本文介绍了使用REST API或Java SDK检索VM CPU百分比度量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索最近30分钟的CPU百分比指标数据,但获得

I am trying to retrieve CPU Percent metric data for last 30 minutes, but getting

values {}

以下是我使用的网址:

https://management.azure.com/subscriptions/mysubscriptionid/resourceGroups/myresgrp/providers/Microsoft.Compute/virtualMachines/myvmname/providers/microsoft.insights/metrics?api-version=2018-01-01


            RestTemplate rest = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            headers.add("Content-Type", "application/json");
            headers.add("Authorization", "Bearer " + token);
            headers.add("Accept", "application/json");
            HttpEntity<String> requestEntity = new HttpEntity<String>("", headers);

获取响应状态代码为200,但值为EMPTY。有什么建议吗?

Getting response status code as 200, but values are EMPTY. Any suggestions?

推荐答案

我尝试了你用过的其余api。它的列表指标。

I tried the rest api which you have used. Its listing metrics for me.

您可以访问此Monitor API  网址 并在浏览器中试用。

You can go to this Monitor API URL and try out in the browser itself.

默认情况下,它会选择最近一小时的数据。

By default it picks the data for the last one hour.

此处几乎没有检查以确保您获得指标。

Few checks here to make sure you get the metrics.


  • 检查您的虚拟机是否正在运行。如果您在不传递时间戳的情况下查询数据,则选择最后一小时。因此,您的计算机应处于运行状态以获得指标。
  • 检查您是否能够在虚拟机刀片中查看指标。

尝试这个,让我知道。


这篇关于使用REST API或Java SDK检索VM CPU百分比度量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆