atsag
atsag

Reputation: 93

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

I monitor the execution of an Azure function using the Live Metrics Stream management UI as seen below:Live Metrics Management 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?

Upvotes: 1

Views: 904

Answers (1)

ZakiMa
ZakiMa

Reputation: 6241

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:

enter image description here

2) Use the API reference to run "Query"

Upvotes: 2

Related Questions