Metrics - Get
擷取計量數據
取得單一計量的計量值
GET https://api.applicationinsights.io/v1/apps/{appId}/metrics/{metricId}
GET https://api.applicationinsights.io/v1/apps/{appId}/metrics/{metricId}?timespan={timespan}&interval={interval}&aggregation={aggregation}&segment={segment}&top={top}&orderby={orderby}&filter={filter}
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
app
|
path | True |
string |
應用程式的識別碼。 這是 Azure 入口網站中 [API 存取設定] 刀鋒視窗的應用程式識別碼。 |
|
metric
|
path | True |
計量的標識碼。 這是標準 AI 計量或應用程式特定的自訂計量。 |
|
|
aggregation
|
query |
計算計量值時要使用的匯總。 若要一次擷取多個匯總,請以逗號分隔它們。 如果未指定任何匯總,則會使用計量的預設匯總。 |
||
|
filter
|
query |
string |
用來篩選結果的表達式。 此值應該是有效的 OData 篩選表達式,其中每個子句的索引鍵應該是您所擷取計量的適用維度。 |
|
|
interval
|
query |
string (duration) |
擷取計量值時要使用的時間間隔。 這是ISO8601持續時間。 如果省略 interval,則會跨整個時間範圍匯總計量值。 如果提供 interval,伺服器可能會根據查詢所使用的時間範圍,將間隔調整為更適當的大小。 在所有情況下,用於查詢的實際間隔都會包含在回應中。 |
|
|
orderby
|
query |
string |
排序區段的聚合函數和方向。 只有在指定區段時,這個值才有效。 |
|
|
segment
|
query |
要分割計量值所依據的維度名稱。 此維度必須適用於您正在擷取的計量。 若要一次分割多個維度,請以逗號 (,, ) 分隔它們。 在此情況下,計量數據會依維度列在 參數中的順序進行區隔。 |
||
|
timespan
|
query |
string |
要擷取計量值的時間範圍。 這是ISO8601時間週期值。 如果省略 timespan,則會使用預設時間範圍 |
|
|
top
|
query |
integer (int32) |
要傳回的區段數目。 只有在指定區段時,這個值才有效。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 200 OK |
成功回應 |
|
| Other Status Codes |
錯誤回應物件。 |
安全性
oauth2
連線到 Azure Application Insights API
類型:
oauth2
Flow:
implicit
授權 URL:
https://login.microsoftonline.com/common/oauth2/authorize?resource=https%3A%2F%2Fapi.applicationinsights.io
範圍
| 名稱 | Description |
|---|---|
| user_impersonation | 模擬您的用戶帳戶 |
範例
|
intervaled |
|
segmented |
|
simple |
intervaledMetric
範例要求
GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount?timespan=P2D&interval=P1D
範例回覆
{
"value": {
"start": "2018-02-04T10:01:35.086Z",
"end": "2018-02-06T10:01:35.086Z",
"interval": "P1D",
"segments": [
{
"start": "2018-02-04T10:01:35.086Z",
"end": "2018-02-05T00:00:00.000Z",
"requests/count": {
"sum": 4927
}
},
{
"start": "2018-02-05T00:00:00.000Z",
"end": "2018-02-06T00:00:00.000Z",
"requests/count": {
"sum": 8460
}
},
{
"start": "2018-02-06T00:00:00.000Z",
"end": "2018-02-06T10:01:35.086Z",
"requests/count": {
"sum": 3743
}
}
]
}
}
segmentedIntervaledMetric
範例要求
GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount?timespan=P2D&interval=P1D&segment=operation/name,request/success
範例回覆
{
"value": {
"start": "2018-10-22T10:40:09.065Z",
"end": "2018-10-22T22:40:09.065Z",
"segments": [
{
"operation/name": "GET Home/Index",
"segments": [
{
"requests/count": null,
"sum": 156483,
"request/success": false
},
{
"requests/count": null,
"sum": 3795,
"request/success": true
}
]
},
{
"operation/name": "GET /",
"segments": [
{
"requests/count": null,
"sum": 34168,
"request/success": false
},
{
"requests/count": null,
"sum": 12,
"request/success": true
}
]
},
{
"operation/name": "GET /FabrikamProd/Content/fonts/segoewp-light-webfont.eot",
"segments": [
{
"requests/count": null,
"sum": 9378,
"request/success": true
}
]
},
{
"operation/name": "GET /FabrikamProd/Content/fonts/segoewp-webfont.eot",
"segments": [
{
"requests/count": null,
"sum": 9370,
"request/success": true
}
]
},
{
"operation/name": "GET ServiceTickets/Details",
"segments": [
{
"requests/count": null,
"sum": 1989,
"request/success": false
},
{
"requests/count": null,
"sum": 14,
"request/success": true
}
]
},
{
"operation/name": "GET ServiceTickets/Index",
"segments": [
{
"requests/count": null,
"sum": 1991,
"request/success": true
}
]
},
{
"operation/name": "GET Employees/Index",
"segments": [
{
"requests/count": null,
"sum": 1990,
"request/success": true
}
]
},
{
"operation/name": "GET ServiceTickets/GetLogEntries",
"segments": [
{
"requests/count": null,
"sum": 1985,
"request/success": true
}
]
},
{
"operation/name": "GET Employees/Details",
"segments": [
{
"requests/count": null,
"sum": 663,
"request/success": false
},
{
"requests/count": null,
"sum": 663,
"request/success": true
}
]
},
{
"operation/name": "GET Reports/Index",
"segments": [
{
"requests/count": null,
"sum": 1086,
"request/success": true
}
]
}
]
}
}
simpleMetric
範例要求
GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount
範例回覆
{
"value": {
"start": "2016-01-01T02:00:00.000Z",
"end": "2016-01-03T02:00:00.000Z",
"requests/count": {
"sum": 23
}
}
}
定義
| 名稱 | Description |
|---|---|
|
error |
錯誤詳細數據。 |
|
error |
錯誤的程式代碼和訊息。 |
|
error |
錯誤詳細數據。 |
|
Metric |
計量的標識碼。 這是標準 AI 計量或應用程式特定的自訂計量。 |
|
Metrics |
計算計量值時要使用的匯總。 若要一次擷取多個匯總,請以逗號分隔它們。 如果未指定任何匯總,則會使用計量的預設匯總。 |
|
metrics |
計量結果。 |
|
metrics |
計量結果數據。 |
|
Metrics |
要分割計量值所依據的維度名稱。 此維度必須適用於您正在擷取的計量。 若要一次分割多個維度,請以逗號 (,, ) 分隔它們。 在此情況下,計量數據會依維度列在 參數中的順序進行區隔。 |
|
metrics |
計量區段 |
errorDetail
錯誤詳細數據。
| 名稱 | 類型 | Description |
|---|---|---|
| additionalProperties |
object |
|
| code |
string |
錯誤的程序代碼。 |
| message |
string |
人類可讀取的錯誤訊息。 |
| resources |
string[] |
指出負責錯誤的資源。 |
| target |
string |
指出要求中的哪一個屬性負責錯誤。 |
| value |
string |
指出 『target』 中的哪個值會負責錯誤。 |
errorInfo
錯誤的程式代碼和訊息。
| 名稱 | 類型 | Description |
|---|---|---|
| additionalProperties |
object |
|
| code |
string |
計算機可讀取的錯誤碼。 |
| details |
錯誤詳細數據。 |
|
| innererror |
錯誤的程式代碼和訊息。 |
|
| message |
string |
人類可讀取的錯誤訊息。 |
errorResponse
錯誤詳細數據。
| 名稱 | 類型 | Description |
|---|---|---|
| error |
錯誤的程式代碼和訊息。 |
MetricId
計量的標識碼。 這是標準 AI 計量或應用程式特定的自訂計量。
| 值 | Description |
|---|---|
| requests/count | |
| requests/duration | |
| requests/failed | |
| users/count | |
| users/authenticated | |
| pageViews/count | |
| pageViews/duration | |
| client/processingDuration | |
| client/receiveDuration | |
| client/networkDuration | |
| client/sendDuration | |
| client/totalDuration | |
| dependencies/count | |
| dependencies/failed | |
| dependencies/duration | |
| exceptions/count | |
| exceptions/browser | |
| exceptions/server | |
| sessions/count | |
| performanceCounters/requestExecutionTime | |
| performanceCounters/requestsPerSecond | |
| performanceCounters/requestsInQueue | |
| performanceCounters/memoryAvailableBytes | |
| performanceCounters/exceptionsPerSecond | |
| performanceCounters/processCpuPercentage | |
| performanceCounters/processIOBytesPerSecond | |
| performanceCounters/processPrivateBytes | |
| performanceCounters/processorCpuPercentage | |
| availabilityResults/availabilityPercentage | |
| availabilityResults/duration | |
| billing/telemetryCount | |
| customEvents/count |
MetricsAggregation
計算計量值時要使用的匯總。 若要一次擷取多個匯總,請以逗號分隔它們。 如果未指定任何匯總,則會使用計量的預設匯總。
| 值 | Description |
|---|---|
| min | |
| max | |
| avg | |
| sum | |
| count | |
| unique |
metricsResult
計量結果。
| 名稱 | 類型 | Description |
|---|---|---|
| value |
計量結果數據。 |
metricsResultInfo
計量結果數據。
| 名稱 | 類型 | Description |
|---|---|---|
| end |
string (date_time) |
計量的開始時間。 |
| interval |
string (duration) |
用來分割計量數據的間隔。 |
| segments |
分段計量數據(如果已區隔)。 |
|
| start |
string (date_time) |
計量的開始時間。 |
MetricsSegment
要分割計量值所依據的維度名稱。 此維度必須適用於您正在擷取的計量。 若要一次分割多個維度,請以逗號 (,, ) 分隔它們。 在此情況下,計量數據會依維度列在 參數中的順序進行區隔。
| 值 | Description |
|---|---|
| applicationBuild | |
| applicationVersion | |
| authenticatedOrAnonymousTraffic | |
| browser | |
| browserVersion | |
| city | |
| cloudRoleName | |
| cloudServiceName | |
| continent | |
| countryOrRegion | |
| deploymentId | |
| deploymentUnit | |
| deviceType | |
| environment | |
| hostingLocation | |
| instanceName |
metricsSegmentInfo
計量區段
| 名稱 | 類型 | Description |
|---|---|---|
| end |
string (date_time) |
計量區段的開始時間(只有在指定間隔時)。 |
| segments |
分段計量數據(如果進一步區隔)。 |
|
| start |
string (date_time) |
計量區段的開始時間(只有在指定間隔時)。 |