How can I retrieve through an API *Live Metrics* of Microsoft Application Insights

夙愿已清 提交于 2021-01-28 08:21:07

问题


I monitor the execution of an Azure function using the Live Metrics Stream management UI as seen below: Some of these metrics can be retrieved through the Application Insights REST API. However, metrics concerning overall health data, or Servers data, return a null value. For example,the performanceCounters/processCpuPercentage endpoint produces the following output when probed:

HTTP/1.1 200
content-type: application/json; charset=utf-8
{
  "value": {
    "start": "2018-10-16T11:20:37.366Z",
    "end": "2018-10-16T12:20:37.366Z",
    "performanceCounters/processCpuPercentage": {
      "avg": null
    }
  }
}

Is there a way to get the information appearing under the overall health and servers rows in the UI, through the API?


回答1:


It is not possible to retrieve live data at the moment.

For retrieving historical data you need the following.

1) First to come up with a query which returns data you're interested in. Here is an example (shows Request Count, 95th CPU, 95th Request Duration by Server):

let start = ago(1d);
requests
| where timestamp > start
| summarize ["RequestCount"]=count(), ["Duration"]=percentile(duration, 95) by cloud_RoleInstance
| join (
    performanceCounters
    | where timestamp > start
    | where name == "% Processor Time Normalized"
    | where category == "Process"
    | summarize ["CPU"]=percentile(value, 95) by cloud_RoleInstance
) on cloud_RoleInstance
| project cloud_RoleInstance, RequestCount, Duration, CPU
| order by RequestCount 

You can adjust Analytics query the way you need.

Example output:

2) Use the API reference to run "Query"



来源:https://stackoverflow.com/questions/52839073/how-can-i-retrieve-through-an-api-live-metrics-of-microsoft-application-insigh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!